module documentation
(source)

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
def dates_for_week(year, week): (source)
Returns the first and last day of the week for a given week number of a given year.
Parameters
yearyear as int (e.g. 2012)
weekweek number as int (0 .. 53)
Returns

a 2-tuple of:

  • a datetime.date object for the start date of the week
  • a datetime.date object for the end dateof the week
Note
first day of the week can be either MONDAY or SUNDAY, this is configured in FIRST_DAY_OF_WEEK based on the locale.
def init_first_day_of_week(): (source)

Undocumented

def now(): (source)
Like datetime.now() but with local timezone info
def strfcal(format, date): (source)

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:

  • %w is replaced by the weekday as a decimal number [1,7], with 1 representing either Monday or Sunday depending on the locale
  • %W is replaced by the weeknumber depending on the locale
  • %Y is replaced by the year with century as a decimal number, the year depends on the weeknumber depending on the locale
  • %% is replaced by %

Difference between this method and strftime is that:

  1. It uses locale to determine the first day of the week
  2. It returns the year that goes with the weeknumber
def strftime(format, date): (source)

Undocumented

def weekcalendar(date): (source)
Get the year, week number and week day for a specific date. Like datetime.date.isocalendar() but takes into account FIRST_DAY_OF_WEEK correctly.
Parameters
datea 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.
DSTDIFF = (source)

Undocumented

Value
DSTOFFSET-STDOFFSET
DSTOFFSET = (source)

Undocumented

Value
STDOFFSET
FIRST_DAY_OF_WEEK = (source)

Undocumented

Value
None
MONDAY: int = (source)

Undocumented

Value
0
STDOFFSET = (source)

Undocumented

Value
timedelta(seconds=-_time.timezone)
SUNDAY: int = (source)

Undocumented

Value
6
ZERO = (source)

Undocumented

Value
timedelta(0)
logger = (source)

Undocumented