Sample: cleaning up Inheritance
[io/quag.git] / libs / basekit / source / Date.h
blob3df6909fcdc721f254438b1761839c353e67f621
1 /*#io
2 docCopyright("Steve Dekorte", 2002)
3 docLicense("BSD revised")
4 */
6 #include "Base.h"
8 #ifndef DATE_DEFINED
9 #define DATE_DEFINED 1
11 #include "Common.h"
12 #include "Duration.h"
13 #include "PortableGettimeofday.h"
14 #include <time.h>
16 #ifdef __cplusplus
17 extern "C" {
18 #endif
20 typedef struct
22 struct timeval tv;
23 struct timezone tz;
24 } Date;
26 BASEKIT_API Date *Date_new(void);
27 BASEKIT_API void Date_copy_(Date *self, const Date *other);
28 BASEKIT_API void Date_free(Date *self);
29 BASEKIT_API int Date_compare(const Date *self, const Date *other);
31 BASEKIT_API void Date_now(Date *self);
32 BASEKIT_API void Date_setToLocalTimeZone(Date *self);
33 BASEKIT_API double Date_Clock(void);
35 BASEKIT_API void Date_fromLocalTime_(Date *self, struct tm *t);
36 BASEKIT_API void Date_fromTime_(Date *self, time_t t);
37 BASEKIT_API time_t Date_asTime(const Date *self);
39 // zone
41 BASEKIT_API void Date_setToLocalTimeZone(Date *self);
42 struct timezone Date_timeZone(const Date *self);
43 BASEKIT_API void Date_setTimeZone_(Date *self, struct timezone tz);
44 BASEKIT_API void Date_convertToTimeZone_(Date *self, struct timezone tz);
46 // components
48 BASEKIT_API void Date_setYear_(Date *self, long y);
49 BASEKIT_API long Date_year(const Date *self);
51 BASEKIT_API void Date_setMonth_(Date *self, int m);
52 BASEKIT_API int Date_month(const Date *self);
54 BASEKIT_API void Date_setDay_(Date *self, int d);
55 BASEKIT_API int Date_day(const Date *self);
57 BASEKIT_API void Date_setHour_(Date *self, int h);
58 BASEKIT_API int Date_hour(const Date *self);
60 BASEKIT_API void Date_setMinute_(Date *self, int m);
61 BASEKIT_API int Date_minute(const Date *self);
63 BASEKIT_API void Date_setSecond_(Date *self, double s);
64 BASEKIT_API double Date_second(const Date *self);
66 BASEKIT_API unsigned char Date_isDaylightSavingsTime(const Date *self);
67 BASEKIT_API int Date_isLeapYear(const Date *self);
69 // seconds
71 BASEKIT_API double Date_asSeconds(const Date *self);
72 BASEKIT_API void Date_fromSeconds_(Date *self, double s);
74 BASEKIT_API void Date_addSeconds_(Date *self, double s);
75 BASEKIT_API double Date_secondsSince_(const Date *self, const Date *other);
77 // format
79 BASEKIT_API void Date_fromString_format_(Date *self, const char *s, const char *format);
81 // durations
83 BASEKIT_API Duration *Date_newDurationBySubtractingDate_(const Date *self, const Date *other);
84 BASEKIT_API void Date_addDuration_(Date *self, const Duration *d);
85 BASEKIT_API void Date_subtractDuration_(Date *self, const Duration *d);
87 BASEKIT_API double Date_secondsSinceNow(const Date *self);
89 BASEKIT_API UArray *Date_asString(const Date *self, const char *format);
91 #ifdef __cplusplus
93 #endif
94 #endif