Daylight Savings Time

This will take an igor timestamp (seconds since midnight on 1/1/1904) and return the truth about whether that timestamp occurred during a daylight savings time epoch, based on the daylight savings time rules effective in most of the United States since 2007. This is useful in cases when comparing the output generated by an Igor command like date2secs, which does not incorporate daylight savings time rules, and the output of a command like DateTime, which uses the system clock and therefore does apply daylight savings time rules. 3600*DST(timeStamp) can then be added or subtracted to a timeStamp to harmonize it with daylight savings time.

Example:
Variable /G test=date2secs(2009,01,01)+3600
print secs2date(test,1), secs2time(test,1) // prints Thursday, January 01, 2009 1:00:00 AM
print DST(test) // prints 0
Variable /G test=date2secs(2009,04,01)+3600
print DST(test) // prints 1

// Returns 1 if the specified Igor timestamp falls in a daylight savings time epoch.
Function DST(timeStamp)
Variable timeStamp

Variable day,month,year,dayOfWeek,hours,minutes
String date_=Secs2Date(timeStamp,-1)
sscanf date_,"%d/%d/%d (%d)",day,month,year,dayOfWeek
String time_=Secs2Time(timeStamp,2)
sscanf time_,"%d:%d",hours,minutes
switch(month)
case 1:
case 2:
return 0
break
case 3:
Variable minDay=dayOfWeek+7*1 // Second sunday.
if(day>=minDay && (dayOfWeek!=1 || hours>=2))
return 1
else
return 0
endif
break
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
return 1
break
case 11:
minDay=dayOfWeek+7*0 // First sunday.
if(day>=minDay && (dayOfWeek!=1 || hours>=2))
return 0
else
return 1
endif
break
break
case 12:
return 0
break
default:
print "No such month:"+num2str(month)
endswitch
End

Forum

Support

Gallery

Igor Pro 8

Learn More

Igor XOP Toolkit

Learn More

Igor NIDAQ Tools MX

Learn More