Show More
@@ -1583,7 +1583,19 b' def makedate(timestamp=None):' | |||||
1583 | def datestr(date=None, format='%a %b %d %H:%M:%S %Y %1%2'): |
|
1583 | def datestr(date=None, format='%a %b %d %H:%M:%S %Y %1%2'): | |
1584 | """represent a (unixtime, offset) tuple as a localized time. |
|
1584 | """represent a (unixtime, offset) tuple as a localized time. | |
1585 | unixtime is seconds since the epoch, and offset is the time zone's |
|
1585 | unixtime is seconds since the epoch, and offset is the time zone's | |
1586 |
number of seconds away from UTC. |
|
1586 | number of seconds away from UTC. | |
|
1587 | ||||
|
1588 | >>> datestr((0, 0)) | |||
|
1589 | 'Thu Jan 01 00:00:00 1970 +0000' | |||
|
1590 | >>> datestr((42, 0)) | |||
|
1591 | 'Thu Jan 01 00:00:42 1970 +0000' | |||
|
1592 | >>> datestr((-42, 0)) | |||
|
1593 | 'Wed Dec 31 23:59:18 1969 +0000' | |||
|
1594 | >>> datestr((0x7fffffff, 0)) | |||
|
1595 | 'Tue Jan 19 03:14:07 2038 +0000' | |||
|
1596 | >>> datestr((-0x80000000, 0)) | |||
|
1597 | 'Fri Dec 13 20:45:52 1901 +0000' | |||
|
1598 | """ | |||
1587 | t, tz = date or makedate() |
|
1599 | t, tz = date or makedate() | |
1588 | if "%1" in format or "%2" in format or "%z" in format: |
|
1600 | if "%1" in format or "%2" in format or "%z" in format: | |
1589 | sign = (tz > 0) and "-" or "+" |
|
1601 | sign = (tz > 0) and "-" or "+" |
General Comments 0
You need to be logged in to leave comments.
Login now