Code: Select all
# Northern Hemisphere Daylight Saving code (London example)
tz = 0 # Time zone (GMT+0)London time Zone
t = Time.now.utc + (tz*60*60)
# day month in MMDD form. example march/6 = 0306
dstimeStartday = "0328" # Start of London SummerTime March/28 2010
dstimeEndday = "1031" # End of London SummerTime October/31 2010
if (dstimeStartday...dstimeEndday) === t.strftime("%m%d") # Check if todays date is in DST Date range.
t = Time.now.utc + ((tz+1)*60*60) # if true add 1 hour to tz TimeZone.
end
logtime = t.strftime("%A(%w) (%H%M)%I:%M%p %Y(%m%d)") # Check Day Time and Date in Console output.
sys.log("#{logtime}")
Code: Select all
# Southern Hemisphere Daylight Saving code (Australian example)
tz = +10 # Time zone (GMT+10 hours)Sydney AEST time Zone
t = Time.now.utc + (tz*60*60)
# day month in MMDD form. example march/6 (0306)
dstimeStartday = "1003" # Start of Sydney DaylightSavingTime October/03 2010
dstimeEndday = "0403" # End of Sydney DaylightSavingTime April/03 2011
if !( (dstimeEndday...dstimeStartday) === t.strftime("%m%d") ) # Check if todays date is outside DST Date range.
t = Time.now.utc + ((tz+1)*60*60) # if false add 1 hour to tz TimeZone.
end
logtime = t.strftime("%A(%w) (%H%M)%I:%M%p %Y(%m%d)") # Check Day Time and Date in Console output.
sys.log("#{logtime}")