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

dateTime was ignoring specified local_or_utc value #55

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

TranscendOfSypherus
Copy link

@TranscendOfSypherus TranscendOfSypherus commented Aug 3, 2019

Line 1210: always assumed the provided time_t was in local time.

thus the following output:

Timezone localTz;
localTz.setLocation("Australia/Melbourne");

// -- works for TIME_NOW as it gets hydrated in local time
Serial.println("Current Time: ");
Serial.print("         UTC: "); Serial.println(UTC.dateTime());
Serial.print("       Local: "); Serial.println(localTz.dateTime());
Serial.println();

// Current Time:
//          UTC: Saturday, 03-Aug-2019 03:56:27 UTC
//        Local: Saturday, 03-Aug-2019 13:56:27 AEST

time_t testTime = 1564953937;
Serial.println("    Simulate: ");
Serial.print("       Local: "); Serial.println(localTz.dateTime(testDate));
Serial.print("       Local: "); Serial.println(localTz.dateTime(testDate, LOCAL_TIME));
Serial.print("       Local: "); Serial.println(localTz.dateTime(testDate, UTC_TIME));

//  Simulate:
//       UTC: Sunday, 04-Aug-2019 21:25:37 UTC
//     Local: Sunday, 04-Aug-2019 11:25:37 AEST
//     Local: Sunday, 04-Aug-2019 11:25:37 AEST
//     Local: Sunday, 04-Aug-2019 11:25:37 AEST <--- wrong

with this PR:

// Current Time:
//          UTC: Saturday, 03-Aug-2019 03:56:27 UTC
//        Local: Saturday, 03-Aug-2019 13:56:27 AEST
//
//  Simulate:
//       UTC: Sunday, 04-Aug-2019 21:25:37 UTC
//     Local: Sunday, 04-Aug-2019 11:25:37 AEST
//     Local: Sunday, 04-Aug-2019 11:25:37 AEST
//     Local: Monday, 05-Aug-2019 07:25:37 AEST <--- correct

Line 1210: always assumed the provided time_t was in local time.

thus the following output:

Timezone localTz;
localTz.setLocation("Australia/Melbourne");

// -- works for TIME_NOW as it gets hydrated in local time
Serial.println("Current Time: ");
Serial.print("         UTC: "); Serial.println(UTC.dateTime());
Serial.print("       Local: "); Serial.println(localTz.dateTime());
Serial.println();

// Current Time:
//          UTC: Saturday, 03-Aug-2019 03:56:27 UTC
//        Local: Saturday, 03-Aug-2019 13:56:27 AEST

time_t testTime = 1564953937;
Serial.println("    Simulate: ");
Serial.print("       Local: "); Serial.println(localTz.dateTime(testDate));
Serial.print("       Local: "); Serial.println(localTz.dateTime(testDate, LOCAL_TIME));
Serial.print("       Local: "); Serial.println(localTz.dateTime(testDate, UTC_TIME));

// Simulate:
//       UTC: Sunday, 04-Aug-2019 21:25:37 UTC
//     Local: Sunday, 04-Aug-2019 11:25:37 AEST
//     Local: Sunday, 04-Aug-2019 11:25:37 AEST
//     Local: Sunday, 04-Aug-2019 11:25:37 AEST <--- wrong

with this PR:
// Current Time:
//          UTC: Saturday, 03-Aug-2019 03:56:27 UTC
//        Local: Saturday, 03-Aug-2019 13:56:27 AEST
//
// Simulate:
//       UTC: Sunday, 04-Aug-2019 21:25:37 UTC
//     Local: Sunday, 04-Aug-2019 11:25:37 AEST
//     Local: Sunday, 04-Aug-2019 11:25:37 AEST
//     Local: Monday, 05-Aug-2019 07:25:37 AEST <--- correct
@Scratchydisk
Copy link

Thanks Transend... I can confirm this addresses an issue I was having when converting UTC to BST.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants