Skip to content

Commit a03c84a

Browse files
Merge pull request #362 from csnol/master
Add TimeZone(UnixTime, HourOffset, MinuteOffset)
2 parents cd7b7d7 + 588f9db commit a03c84a

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

STM32F1/libraries/RTClock/src/RTClock.cpp

100644100755
File mode changed.

STM32F1/libraries/RTClock/src/RTClock.h

100644100755
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,12 @@ class RTClock {
7171
uint8_t minute(time_t t) { breakTime(t, tmm); return tmm.minute; }
7272
uint8_t second(time_t t) { breakTime(t, tmm); return tmm.second; }
7373
uint8_t isPM(time_t t) { return (hour(t)>=12); }
74+
75+
// Usage: localtime = TimeZone(UnixTime, 8);
76+
time_t TimeZone(time_t t, int TZ) { return ( t + (TZ * SECS_PER_HOUR)); }
7477

75-
time_t TimeZone(time_t t, int TZ) { return ( t + (TZ * SECS_PER_HOUR)); } // usage: localtime = TimeZone(UnixTime, 8); // Beijing timezone = 8
78+
// Usage: 1. localtime = TimeZone(UnixTime, 9, 45) -> UTC +09:45 TimeZone;
79+
time_t TimeZone(time_t t, int HTZ, int MTZ) { return ( t + (HTZ * SECS_PER_HOUR) + (MTZ * 60)); } // HTZ = Hour offset, MTZ = Minute offset
7680

7781
void createAlarm(voidFuncPtr function, time_t alarm_time_t);
7882
void createAlarm(voidFuncPtr function, struct tm_t & alarm_tm);

0 commit comments

Comments
 (0)