Download or view timezonediff.frink in plain text format
// Function to determine the difference between two time zones. This is
// somewhat tricky because the difference between time zones may change several
// times over the course of a year because of Daylight Saving / Summer Time
// changes which may not occur at the same time. This means that the exact
// date/time for which the conversion is to happen must be specified.
//
// This function takes three arguments:
// [z1, z2, time]
// Where z1 and z2 are strings indicating the name of a timezone and
// the optional argument time is a string indicating the date and time for
// which the conversion is to be calculated. The default is to use the
// current time in timezone z1.
// The return value is the time to be *added* to the local time in timezone z1
// to get the local time in timezone z2.
timezonediff[z1, z2, time=undef] :=
{
if (time == undef)
{
fmt = ### yyyy-MM-dd HH:mm:ss.SSS ###
time = now[] -> [fmt, z1]
}
t1 = parseDate["$time $z1"]
t2 = parseDate["$time $z2"]
return t1 - t2
}
Download or view timezonediff.frink in plain text format
This is a program written in the programming language Frink.
For more information, view the Frink
Documentation or see More Sample Frink Programs.
Alan Eliasen was born 20217 days, 17 hours, 58 minutes ago.