From e7b146fb3bdca62a0d5ecc06dbf3348e5a4fe757 Mon Sep 17 00:00:00 2001 From: Guido van Rossum Date: Fri, 4 Feb 2000 15:28:42 +0000 Subject: The third and final doc-string sweep by Ka-Ping Yee. The attached patches update the standard library so that all modules have docstrings beginning with one-line summaries. A new docstring was added to formatter. The docstring for os.py was updated to mention nt, os2, ce in addition to posix, dos, mac. --- Lib/tzparse.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'Lib/tzparse.py') diff --git a/Lib/tzparse.py b/Lib/tzparse.py index 358e0cc25e..fa94bd5493 100644 --- a/Lib/tzparse.py +++ b/Lib/tzparse.py @@ -1,4 +1,5 @@ -# Parse a timezone specification. +"""Parse a timezone specification.""" + # XXX Unfinished. # XXX Only the typical form "XXXhhYYY;ddd/hh,ddd/hh" is currently supported. @@ -8,6 +9,12 @@ tzpat = ('^([A-Z][A-Z][A-Z])([-+]?[0-9]+)([A-Z][A-Z][A-Z]);' tzprog = None def tzparse(tzstr): + """Given a timezone spec, return a tuple of information + (tzname, delta, dstname, daystart, hourstart, dayend, hourend), + where 'tzname' is the name of the timezone, 'delta' is the offset + in hours from GMT, 'dstname' is the name of the daylight-saving + timezone, and 'daystart'/'hourstart' and 'dayend'/'hourend' + specify the starting and ending points for daylight saving time.""" global tzprog if tzprog == None: import re @@ -24,6 +31,9 @@ def tzparse(tzstr): return (tzname, delta, dstname, daystart, hourstart, dayend, hourend) def tzlocaltime(secs, params): + """Given a Unix time in seconds and a tuple of information about + a timezone as returned by tzparse(), return the local time in the + form (year, month, day, hour, min, sec, yday, wday, tzname).""" import time (tzname, delta, dstname, daystart, hourstart, dayend, hourend) = params year, month, days, hours, mins, secs, yday, wday, isdst = \ @@ -34,6 +44,7 @@ def tzlocaltime(secs, params): return year, month, days, hours, mins, secs, yday, wday, tzname def tzset(): + """Determine the current timezone from the "TZ" environment variable.""" global tzparams, timezone, altzone, daylight, tzname import os tzstr = os.environ['TZ'] @@ -44,6 +55,8 @@ def tzset(): tzname = tzparams[0], tzparams[2] def isdst(secs): + """Return true if daylight-saving time is in effect for the given + Unix time in the current timezone.""" import time (tzname, delta, dstname, daystart, hourstart, dayend, hourend) = \ tzparams @@ -54,6 +67,7 @@ def isdst(secs): tzset() def localtime(secs): + """Get the local time in the current timezone.""" return tzlocaltime(secs, tzparams) def test(): -- cgit v1.2.1