AT&T Home | AT&T Labs | Research
AT&T Labs, Inc. - Research

The Yoix® Scripting Language

Home | What's New | Grammar | Documentation | Download | License | YChart | YDAT | YWAIT | Byzgraf | FAQs
TimeZone typedict
 
A TimeZone is the Yoix representation of the Java TimeZone class. The fields in a TimeZone are:
displayname(int longstyle[, int dst[, Locale locale]]) Returns a String that is the displayed name of this timezone. When non-zero, longstyle indicates that a long-format should be used in constructing the output, otherwise a short-format is used. When provided and non-zero, dst indicates that the DST form should be used. Providing a locale will adjust the format and language of the output appropriately.
dst(Number unixtime) If the time indicated by unixtime falls within the limits of daylight savings time this timezone, then a non-zero value is returned. Otherwise, zero is returned.

In the following example, two dates are tested for occurring during a period of Eastern Daylight Savings Time.

import yoix.stdio.*;
import yoix.util.*;

Calendar cal;
TimeZone zone = getTimeZone("EST");

cal.set(2006, 5, 1);
printf("%s is%s in daylight savings time\n",
       date(zone, cal.unixtime), (zone.dst(cal.unixtime) ? "" : " not") );
cal.add(Calendar.MONTH, 6);
printf("%s is%s in daylight savings time\n",
       date(zone, cal.unixtime), (zone.dst(cal.unixtime) ? "" : " not") );
The results on standard output are:
Thu Jun  1 11:17:07 EDT 2006 is in daylight savings time
Fri Dec  1 11:17:07 EST 2006 is not in daylight savings time
dstoffset A read-only int representing the number of milliseconds of shift that occurs for daylight savings time (DST). The value is what is added to standard time to achieve daylight savings time. A zero value indicates that daylight savings time is not observed.
id A String giving the timezone identifier (e.g., EST or America/New_York). When NULL or empty, the GMT timezone id is used. Reading gives the current value, while writing immediately sets the ID to the new value. Note that if the ID is not a commonly recognized id, functions such as date that make use of timezone information will use a GMT offset representation when then need to indicate the timezone.
samerules(TimeZone zone) A built-in that returns a non-zero value when the supplied zone is effectively the same as this timezone except, perhaps, in the value of the ID string. If zone is effectively different than this timezone or if it is NULL, then a zero value is returned.
usedst A read-only int that is non-zero when indicating that DST is used or zero otherwise.
zoneoffset An int field giving the offset in milliseconds from GMT (or UTC). The number represents the number of milliseconds that need to be added to GMT time to obtain the time in this zone. For example, the US/Eastern zone would have a value of -18000000. Reading gives the current zone offset value in milliseconds. Writing immediately sets the zone offset to the new value.
Several permanent fields have not been documented and should not be used in Yoix applications.
 
 Example:   The following script retrieves the timezone settings for Athens, Greece and displays the current time in Athens. Then the zone is shifted ahead two hours and the (incorrect) time in Athens is displayed.
import yoix.*.*;

TimeZone zone = getTimeZone("Europe/Athens");
printf("The current time in Athens is: %s\n", date(zone, time()));
zone.zoneoffset += 7200000;
printf("The incorrect time in Athens is: %s\n", date(zone, time()));
The text on standard output would look something like:
The current time in Athens is: Sun Feb 25 18:43:33 EET 2007
The incorrect time in Athens is: Sun Feb 25 20:43:33 EET 2007
 
 See Also:   Calendar, date, getTimeZone, getTimeZoneIDs, Locale, setTimeZone

 

Yoix is a registered trademark of AT&T Inc.