Thin wrapper for 'datetime' module from the standard library. Provides timezone info for the local time. Based on example code from standard library datetime documentation.
Main usage of this module is the function now()
. It imports all from the standard datetime, so it can be used as a transparant replacement.
Also adds a strfcal()
method and extends strftime()
to deal with weeknumbers correctly.
Class | LocalTimezone |
Implementation of tzinfo with the current time zone, based on the platform's idea of local time |
Function | dates_for_week |
No summary |
Function | init_first_day_of_week |
Undocumented |
Function | now |
Like datetime.now() but with local timezone info |
Function | strfcal |
Method similar to strftime, but dealing with the weeknumber, day of the week and the year of that week. |
Function | strftime |
Undocumented |
Function | weekcalendar |
No summary |
Constant | DSTDIFF |
Undocumented |
Constant | DSTOFFSET |
Undocumented |
Constant | FIRST_DAY_OF_WEEK |
Undocumented |
Constant | MONDAY |
Undocumented |
Constant | STDOFFSET |
Undocumented |
Constant | SUNDAY |
Undocumented |
Constant | ZERO |
Undocumented |
Variable | logger |
Undocumented |
Parameters | |
year | year as int (e.g. 2012) |
week | week number as int (0 .. 53) |
Returns | |
a 2-tuple of:
| |
Note | |
first day of the week can be either MONDAY or SUNDAY, this is configured in FIRST_DAY_OF_WEEK based on the locale. |
Method similar to strftime, but dealing with the weeknumber, day of the week and the year of that week.
Week 1 is the first week where the Thursday is in the new year. So e.g. the last day of 2012 is a Monday. And therefore the calendar week for 31 Dec 2012 is already week 1 2013.
The locale decides whether a week starts on Monday (as the ISO standard would have it) or on Sunday. So depending on your locale Sun 6 Jan 2013 is either still week 1 or already the first day of week 2.
Codes supported by this method:
Difference between this method and strftime is that:
Parameters | |
date | a datetime.date or datetime.datetime object |
Returns | |
a year, a week number and a weekday as integers The weekday numbering depends on locale, 1 is always first day of the week, either a Sunday or a Monday. |