Daylight Savings Time
RGerkin
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 9
Learn More
Igor XOP Toolkit
Learn More
Igor NIDAQ Tools MX
Learn More