[Home] [Puzzles & Projects] [Delphi Techniques] [Math topics] [Library] [Utilities]
|
|
Problem DescriptionThis program investigates how Daylight Saving Time start and end dates can be calculated using simple equations without resorting to high level date-time routines. Background & TechniquesDaylight Saving Time is not one of mankind's greatest inventions, but it does
provide an excuse to study the
If we look at the Mod 7 terms, notice that the 6Y-y/4 in Equation 1 says that we are going to add 6 days for every year, except we'll subtract one day for each leap year. On first look this seems counterintuitive since a normal year is 52 weeks + 1 day. But it makes sense if you think in terms of what happens to a particular day of the week from year to year. It's true that the date moves forward by one day per year, but that also means that the day of week moves backward one day or forward 6 days, whichever is more convenient per year. In the strange world of modulo arithmetic, it turns out that (-Y mod 7) is the equivalent to (6Y mod 7) so we could replace 6Y with -Y and (6Y-Y/4) with (-Y-Y/4 = -5Y/4), the same term that appears in the other five equations. The only problem is that whatever day that represents might apply to any 7 day increment before or after that date. Enter the "magic" number added to -5Y/4 that makes the equation apply to a Sunday. These are already provided by the authors for the five equations, but let us find one for the 1st equation if we want to put it into our new "standard" form. For the 1st Sunday in April we'll one known value and solve Day of Month = 7 - (X + 5Y/4) mod 7 for X. Any year should do so we'll try 2012 where April 1 is a Sunday so we need to solve:
So our revised equation for the first Sunday in April is: Day of Month = 7 - (4 + 5Y/4) mod 7. Checking for 2006 and 2013 we get 4 and 7; both correct so 4 seems to be the correct "magic" number Note that none of the equations take into account 100 year and 400 year Leap Year
exception rules so they only provide
valid results from 1900 through 2099. That range is probably sufficient
for DST calculations. Running/Exploring the Program
Suggestions for Further Explorations
|
[Feedback] [Newsletters (subscribe/view)] [About me]Copyright © 2000-2018, Gary Darby All rights reserved. |