The Tzset () method resets the time conversion rules for the library routines that are used. Environment variable TZ Specifies how to complete this operation.
The standard format of the TZ environment variable (spaces are added for clarity):
The code is as follows:
STD offset [DST [offset [, Start[/time], End[/time]]
- STD and DST: three or more alphanumeric give people the time zone abbreviation. These will be spread to time.tzname.
- Offset: Offsets are in the form:. Hh[:mm[:ss]]. This indicates that the value added local time arrives in UTC. If preceded by a "-", the time zone is east of the Prime meridian, otherwise it is the west. If there is no offset following DST, the summer time is assumed to be one hour ahead of the standard time.
- Start[/time], End[/time]: Indicates when changed to and returned from daylight. The start and end date formats are performed in one of the following actions:
- Jn: In Julian date n (1 <= n <= 365). Leap Day is not counted, so the February 28 of each year is the 59th and March 1 is 60 days.
- N: The zero-based Julian date (0<= n<=365). Leap year days are counted, and can refer to February 29.
- MM.N.D: X Days (0<= d<= 6) or week N of the year of the Month m (1 <= n <=5,1<= m <=12, of which 5 per week represents "at the end D-Sun M", which may occur in either of the four or fifth weeks). Week 1 is where D day occurs in the first week. 0 is Sunday.
- Time: This is different from the same format offset, and no leading symbol ("-" or "+") is allowed. By default, if time is not given, it is 02:00:00.
Grammar
The following is the syntax for the Tzset () method:
Time.tzset ()
Parameters
return value
This method does not return any values.
Example
The following example shows the use of the Tzset () method.
#!/usr/bin/pythonimport timeimport osos.environ[' TZ '] = ' est+05edt,m4.1.0,m10.5.0 ' Time.tzset () print time.strftime (' %x%x%Z ') os.environ[' TZ '] = ' aest-10aedt-11,m10.5.0,m3.5.0 ' Time.tzset () print time.strftime ('%x%x%Z ')
When we run the above program, it produces the following results:
13:00:40 02/17/09 est05:00:40 02/18/09 AEDT