Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update NMEAtimezone.ino #113

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions examples/NMEAtimezone/NMEAtimezone.ino
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,8 @@ static const NeoGPS::clock_t zone_offset =
static const uint8_t springHour = 2;
static const uint8_t fallMonth = 11;
static const uint8_t fallDate = 7; // latest 1st Sunday
static const uint8_t fallHour = 2;
static const uint8_t fallHour = 2;
bool northenHemisphere = 1; //Northen Hemisphere = 1
#define CALCULATE_DST

#elif defined(EU_DST)
Expand All @@ -82,7 +83,19 @@ static const NeoGPS::clock_t zone_offset =
static const uint8_t fallMonth = 10;
static const uint8_t fallDate = 31; // latest last Sunday
static const uint8_t fallHour = 1;
bool northenHemisphere = 1; //Northen Hemisphere = 1
#define CALCULATE_DST

#elif defined(AUS_DST)
static const uint8_t springMonth = 10;
static const uint8_t springDate = 7; // latest last Sunday
static const uint8_t springHour = 2;
static const uint8_t fallMonth = 4; //Autumn
static const uint8_t fallDate = 7; // latest last Sunday
static const uint8_t fallHour = 2;
bool NorthenHemisphere = 0; //Northen Hemisphere = 1
#define CALCULATE_DST

#endif

//--------------------------
Expand Down Expand Up @@ -125,9 +138,18 @@ void adjustTime( NeoGPS::time_t & dt )
seconds += zone_offset;

#ifdef CALCULATE_DST
// Then add an hour if DST is in effect
if ((springForward <= seconds) && (seconds < fallBack))
// Then add an hour if DST is in effect for northen hemisphere
if(northenHemisphere){
if ((springForward <= seconds) && (seconds < fallBack)) {
seconds += NeoGPS::SECONDS_PER_HOUR;
}
}
//separate case for southern hemisphere
else {
if (!((springForward >= seconds) && (seconds > fallBack))) {
seconds += NeoGPS::SECONDS_PER_HOUR;
}
}
#endif

dt = seconds; // convert seconds back to a date/time structure
Expand Down