|
15 | 15 | #define SECS_PER_YEAR (SECS_PER_WEEK * 52UL) |
16 | 16 | #define SECS_YR_2000 (946684800UL) // the time at the start of y2k |
17 | 17 | #define LEAP_YEAR(Y) ( ((1970+Y)>0) && !((1970+Y)%4) && ( ((1970+Y)%100) || !((1970+Y)%400) ) ) |
| 18 | +#define HALFTZ 0 |
18 | 19 |
|
19 | 20 | #if !defined(__time_t_defined) // avoid conflict with newlib or other posix libc |
20 | 21 | #warning "Using private time_t definintion" |
@@ -71,8 +72,14 @@ class RTClock { |
71 | 72 | uint8_t minute(time_t t) { breakTime(t, tmm); return tmm.minute; } |
72 | 73 | uint8_t second(time_t t) { breakTime(t, tmm); return tmm.second; } |
73 | 74 | uint8_t isPM(time_t t) { return (hour(t)>=12); } |
| 75 | + |
| 76 | + // Usage: localtime = TimeZone(UnixTime, 8); |
| 77 | + time_t TimeZone(time_t t, int TZ) { return ( t + (TZ * SECS_PER_HOUR)); } |
74 | 78 |
|
75 | | - time_t TimeZone(time_t t, int TZ) { return ( t + (TZ * SECS_PER_HOUR)); } // usage: localtime = TimeZone(UnixTime, 8); // Beijing timezone = 8 |
| 79 | + // Usage: 1. localtime = TimeZone(UnixTime, 9, 1) means SAT +09:30 TimeZone; |
| 80 | + // 2. localtime = TimeZone(UnixTime, -3, 1) means NST,NFT -03:30 TimeZone; |
| 81 | + // 3. TimeZone(UnixTime, 8, 0) same function as TimeZone(UnixTime, 8) -> CCT +08:00 |
| 82 | + time_t TimeZone(time_t t, int TZ, bool HFZ); // HFZ : Half-hour TimeZone flag |
76 | 83 |
|
77 | 84 | void createAlarm(voidFuncPtr function, time_t alarm_time_t); |
78 | 85 | void createAlarm(voidFuncPtr function, struct tm_t & alarm_tm); |
|
0 commit comments