-
Notifications
You must be signed in to change notification settings - Fork 0
/
SimpleDLS.h
32 lines (24 loc) · 1.09 KB
/
SimpleDLS.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once
#include <Arduino.h>
// A simple Daylight Saving Time adjustment class
// Caller provides the dates DLS changes.
// The class adjusts the clock hour to and from display but does not adjust the date
// Intended to be "good enough".
class SimpleDLS
{
public:
static void SetData(const byte* pData);
// Ranges - Hours:0..23, Days:1..31, Months:1..12, Years:0..99
// RTC hour -> Display hour. Use to display RTC time adjusted for DLS
static int GetDisplayHour24();//int ClockHour24, int ClockDay, int ClockMonth, int ClockYear); HACK to save program space, use RTC members
// Display hour -> RTC hour. Use when setting the time
static int GetClockHour24(int DisplayHour24, int ClockDay, int ClockMonth, int ClockYear);
// Returns true if DLS is active
static bool Active(int ClockHour24, int ClockDay, int ClockMonth, int ClockYear, const byte* pData);
// Example DLS data
static const byte m_pNewZealandData[] PROGMEM;
static const byte m_pUnitedStatesData[] PROGMEM;
private:
static unsigned short OrdinalDay(int day, int month);
static const byte* m_pData;
};