Merge pull request #362 from csnol/master

Add TimeZone(UnixTime, HourOffset, MinuteOffset)
This commit is contained in:
Roger Clark 2017-10-31 19:53:33 +11:00 committed by GitHub
commit a03c84a635
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 1 deletions

0
STM32F1/libraries/RTClock/src/RTClock.cpp Normal file → Executable file
View File

6
STM32F1/libraries/RTClock/src/RTClock.h Normal file → Executable file
View File

@ -71,8 +71,12 @@ class RTClock {
uint8_t minute(time_t t) { breakTime(t, tmm); return tmm.minute; }
uint8_t second(time_t t) { breakTime(t, tmm); return tmm.second; }
uint8_t isPM(time_t t) { return (hour(t)>=12); }
// Usage: localtime = TimeZone(UnixTime, 8);
time_t TimeZone(time_t t, int TZ) { return ( t + (TZ * SECS_PER_HOUR)); }
time_t TimeZone(time_t t, int TZ) { return ( t + (TZ * SECS_PER_HOUR)); } // usage: localtime = TimeZone(UnixTime, 8); // Beijing timezone = 8
// Usage: 1. localtime = TimeZone(UnixTime, 9, 45) -> UTC +09:45 TimeZone;
time_t TimeZone(time_t t, int HTZ, int MTZ) { return ( t + (HTZ * SECS_PER_HOUR) + (MTZ * 60)); } // HTZ = Hour offset, MTZ = Minute offset
void createAlarm(voidFuncPtr function, time_t alarm_time_t);
void createAlarm(voidFuncPtr function, struct tm_t & alarm_tm);