1 // 2 // nazghul - an old-school RPG engine 3 // Copyright (C) 2002, 2003 Gordon McNutt 4 // 5 // This program is free software; you can redistribute it and/or modify it 6 // under the terms of the GNU General Public License as published by the Free 7 // Software Foundation; either version 2 of the License, or (at your option) 8 // any later version. 9 // 10 // This program is distributed in the hope that it will be useful, but WITHOUT 11 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 12 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 13 // more details. 14 // 15 // You should have received a copy of the GNU General Public License along with 16 // this program; if not, write to the Free Foundation, Inc., 59 Temple Place, 17 // Suite 330, Boston, MA 02111-1307 USA 18 // 19 // Gordon McNutt 20 // gmcnutt@users.sourceforge.net 21 // 22 #ifndef clock_h 23 #define clock_h 24 25 #include "macros.h" 26 27 BEGIN_DECL 28 29 #define CLOCK_TICKS_PER_MINUTE TURNS_PER_MINUTE 30 31 #define clock_alarm_save(clk,save) ((save)->write((save), "%d\n", (clk))) 32 33 typedef unsigned int clock_alarm_t; 34 35 struct clock { 36 int year; 37 int month; 38 int week; 39 int day_w; // Day of week (0..6) 40 int day; // Day of month (0..27) 41 int hour; 42 int min; 43 int baseTurn; 44 45 unsigned int total_minutes; 46 int tick; 47 int tick_to_change_time; 48 int set : 1; 49 }; 50 51 extern void clock_advance(int ticks); 52 extern void clock_alarm_set(clock_alarm_t *alarm, unsigned int minutes); 53 extern int clock_alarm_is_expired(clock_alarm_t *alarm); 54 extern int clock_alarm_remaining(clock_alarm_t *alarm); 55 extern unsigned int clock_time_of_day(void); 56 extern unsigned int clock_time(void); 57 extern int is_noon(void); 58 extern int is_midnight(void); 59 extern int clock_year(void); 60 extern int clock_month(void); 61 extern int clock_week(void); 62 extern int clock_day(void); 63 extern int clock_hour(void); 64 extern int clock_minute(void); 65 extern int clock_tick(void); 66 67 extern char * vague_time_as_string (void); 68 extern char * time_HHMM_as_string (void); 69 extern char * time_YYYY_MM_DD_as_string (void); 70 71 extern const char * month_name (void); 72 extern const char * week_name (void); 73 extern const char * day_name (void); 74 75 76 #ifdef INCLUDE_UNUSED_CLOCK_ROUTINES 77 extern void clock_reset(struct clock *clock); 78 extern void clock_set_alarm(struct clock *clock, struct clock *offset); 79 extern int clock_alarm_expired(struct clock *clock); 80 #endif 81 82 #ifdef OTHER_TIME_STRING_FUNCTIONS 83 extern const char * time_YYYY_as_string (void); 84 extern const char * time_MM_as_string (void); 85 extern const char * time_DD_as_string (void); 86 #endif // OTHER_TIME_STRING_FUNCTIONS 87 88 END_DECL 89 90 #endif 91