Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- DST_Calc_v1_00.txt 24-Aug-2020
- Calculates U.S. (Only) DST Rollovers
- Steps the year from 2014 through 2027 and
- calulates the DST start and stop days of
- the month in March and November respectively.
- The results are displayed in a table which
- can be compared with the table shown on the
- Wikipedia page in Ref.-2 below.
- Note: The DST start/stop equations do not
- take into account 100 year and 400 year Leap
- Year exception rules so they only provide
- valid results from 2007 through 2099.
- Example Output:
- DST_Calc_v1_00.txt 24-Aug-2020
- These dates are valid for the U.S. only.
- See [2] below for U.S. DST exceptions.
- DST dates are valid for 2007 thru 2099[1].
- All DST changes occur on Sunday at 2AM.
- In Mar. add 1-hour, Nov. subtract 1-hour.
- Mnemonic: Spring Forward - Fall Back
- References:
- 1. http://delphiforfun.org/programs/math_topics/dstcalc.htm
- 2. https://en.wikipedia.org/wiki/Daylight_saving_time_in_the_United_States
- -------------------------------
- Year DST Start DST End
- -------------------------------
- 2014 March 09 November 02
- 2015 March 08 November 01
- 2016 March 13 November 06
- 2017 March 12 November 05
- 2018 March 11 November 04
- 2019 March 10 November 03
- 2020 March 08 November 01
- 2021 March 14 November 07
- 2022 March 13 November 06
- 2023 March 12 November 05
- 2024 March 10 November 03
- 2025 March 09 November 02
- 2026 March 08 November 01
- -------------------------------
- */
- int year, dstStart, dstEnd;
- bool run = true;
- void setup() {
- Serial.begin(115200);
- Serial.println(); //skip past startup SerMon garbage
- Serial.println(); //ditto
- Serial.println(" DST_Calc_v1_00.txt 24-Aug-2020");
- Serial.println(" These dates are valid for the U.S. only.");
- Serial.println(" See [2] below for U.S. DST exceptions.");
- Serial.println(" DST dates are valid for 2007 thru 2099[1].");
- Serial.println(" All DST changes occur on Sunday at 2AM.");
- Serial.println(" In Mar. add 1-hour, Nov. subtract 1-hour.");
- Serial.println(" Mnemonic: Spring Forward - Fall Back");
- Serial.println(" References:");
- Serial.println(" 1. http://delphiforfun.org/programs/math_topics/dstcalc.htm");
- Serial.println(" 2. https://en.wikipedia.org/wiki/Daylight_saving_time_in_the_United_States");
- Serial.println();
- Serial.println(" -------------------------------");
- Serial.print(" Year ");
- Serial.print("DST Start ");
- Serial.println("DST End");
- Serial.println(" -------------------------------");
- }
- void loop() {
- if(run == true) {
- for(year = 2014; year < 2027; year++) {
- dstStart = 14 - ((1 + ((year * 5) / 4)) % 7);
- dstEnd = 7 - ((1 + ((year * 5) / 4)) % 7);
- Serial.print(" ");
- Serial.print(year);
- Serial.print(" ");
- Serial.print("March ");
- if(dstStart < 10) {
- Serial.print("0");
- }
- Serial.print(dstStart);
- Serial.print(" ");
- Serial.print("November ");
- if(dstEnd < 10) {
- Serial.print("0");
- }
- Serial.println(dstEnd);
- if(year == 2026) {
- Serial.println(" -------------------------------");
- Serial.println();
- run = false;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement