Guest User

DST_Calc_v1_00.txt, Calculates U.S. DST Rollovers, Arduino IDE v1.8.12

a guest
Sep 19th, 2020
34
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. DST_Calc_v1_00.txt 24-Aug-2020
  3. Calculates U.S. (Only) DST Rollovers
  4.  
  5. Steps the year from 2014 through 2027 and
  6. calulates the DST start and stop days of
  7. the month in March and November respectively.
  8. The results are displayed in a table which
  9. can be compared with the table shown on the
  10. Wikipedia page in Ref.-2 below.
  11.  
  12. Note: The DST start/stop equations do not
  13. take into account 100 year and 400 year Leap
  14. Year exception rules so they only provide
  15. valid results from 2007 through 2099.
  16.  
  17. Example Output:
  18.  
  19. DST_Calc_v1_00.txt 24-Aug-2020
  20. These dates are valid for the U.S. only.
  21. See [2] below for U.S. DST exceptions.
  22. DST dates are valid for 2007 thru 2099[1].
  23. All DST changes occur on Sunday at 2AM.
  24. In Mar. add 1-hour, Nov. subtract 1-hour.
  25. Mnemonic: Spring Forward - Fall Back
  26. References:
  27. 1. http://delphiforfun.org/programs/math_topics/dstcalc.htm
  28. 2. https://en.wikipedia.org/wiki/Daylight_saving_time_in_the_United_States
  29.  
  30. -------------------------------
  31. Year DST Start DST End
  32. -------------------------------
  33. 2014 March 09 November 02
  34. 2015 March 08 November 01
  35. 2016 March 13 November 06
  36. 2017 March 12 November 05
  37. 2018 March 11 November 04
  38. 2019 March 10 November 03
  39. 2020 March 08 November 01
  40. 2021 March 14 November 07
  41. 2022 March 13 November 06
  42. 2023 March 12 November 05
  43. 2024 March 10 November 03
  44. 2025 March 09 November 02
  45. 2026 March 08 November 01
  46. -------------------------------
  47. */
  48.  
  49. int year, dstStart, dstEnd;
  50. bool run = true;
  51.  
  52. void setup() {
  53. Serial.begin(115200);
  54. Serial.println(); //skip past startup SerMon garbage
  55. Serial.println(); //ditto
  56.  
  57. Serial.println(" DST_Calc_v1_00.txt 24-Aug-2020");
  58. Serial.println(" These dates are valid for the U.S. only.");
  59. Serial.println(" See [2] below for U.S. DST exceptions.");
  60. Serial.println(" DST dates are valid for 2007 thru 2099[1].");
  61. Serial.println(" All DST changes occur on Sunday at 2AM.");
  62. Serial.println(" In Mar. add 1-hour, Nov. subtract 1-hour.");
  63. Serial.println(" Mnemonic: Spring Forward - Fall Back");
  64. Serial.println(" References:");
  65. Serial.println(" 1. http://delphiforfun.org/programs/math_topics/dstcalc.htm");
  66. Serial.println(" 2. https://en.wikipedia.org/wiki/Daylight_saving_time_in_the_United_States");
  67. Serial.println();
  68.  
  69. Serial.println(" -------------------------------");
  70. Serial.print(" Year ");
  71. Serial.print("DST Start ");
  72. Serial.println("DST End");
  73. Serial.println(" -------------------------------");
  74. }
  75.  
  76. void loop() {
  77. if(run == true) {
  78. for(year = 2014; year < 2027; year++) {
  79.  
  80. dstStart = 14 - ((1 + ((year * 5) / 4)) % 7);
  81. dstEnd = 7 - ((1 + ((year * 5) / 4)) % 7);
  82.  
  83. Serial.print(" ");
  84. Serial.print(year);
  85. Serial.print(" ");
  86. Serial.print("March ");
  87. if(dstStart < 10) {
  88. Serial.print("0");
  89. }
  90. Serial.print(dstStart);
  91. Serial.print(" ");
  92. Serial.print("November ");
  93. if(dstEnd < 10) {
  94. Serial.print("0");
  95. }
  96. Serial.println(dstEnd);
  97.  
  98. if(year == 2026) {
  99. Serial.println(" -------------------------------");
  100. Serial.println();
  101. run = false;
  102. }
  103. }
  104. }
  105. }
  106.  
RAW Paste Data