Package common :: Module date
[frames] | no frames]

Module date

source code

Date manipulation helper functions.

Functions
 
get_step(dateobj, nbdays=1) source code
 
datefactory(year, month, day, sampledate) source code
 
weekday(dateobj) source code
 
str2date(datestr, sampledate) source code
 
days_between(start, end) source code
 
get_national_holidays(begin, end)
return french national days off between begin and end
source code
 
add_days_worked(start, days)
adds date but try to only take days worked into account
source code
 
nb_open_days(start, end) source code
 
date_range(begin, end, incday=None, incmonth=None)
yields each date between begin and end
source code
 
strptime(value, format) source code
 
strptime_time(value, format='%H:%M') source code
 
todate(somedate)
return a date from a date (leaving unchanged) or a datetime
source code
 
totime(somedate)
return a time from a time (leaving unchanged), date or datetime
source code
 
todatetime(somedate)
return a date from a date (leaving unchanged) or a datetime
source code
 
datetime2ticks(somedate) source code
 
ticks2datetime(ticks) source code
 
days_in_month(somedate) source code
 
days_in_year(somedate) source code
 
previous_month(somedate, nbmonth=1) source code
 
next_month(somedate, nbmonth=1) source code
 
first_day(somedate) source code
 
last_day(somedate) source code
 
ustrftime(somedate, fmt='%Y-%m-%d')
like strftime, but returns a unicode string instead of an encoded string which may be problematic with localized date.
source code
 
utcdatetime(dt) source code
 
utctime(dt) source code
 
datetime_to_seconds(date)
return the number of seconds since the begining of the day for that date...
source code
 
timedelta_to_days(delta)
return the time delta as a number of seconds
source code
 
timedelta_to_seconds(delta)
return the time delta as a fraction of days
source code
Variables
  DateTimeType = datetime
  endOfMonth = RelativeDateTime(months= 1, day=-1)
  FRENCH_FIXED_HOLIDAYS = {'jour_an': '%s-01-01', 'fete_travail'...
  FRENCH_MOBILE_HOLIDAYS = {'paques2004': '2004-04-12', 'ascensi...
  ONEDAY = timedelta(days= 1)
  ONEWEEK = timedelta(days= 7)
Function Details

date_range(begin, end, incday=None, incmonth=None)

source code 
yields each date between begin and end

:param begin: the start date
:param end: the end date
:param incr: the step to use to iterate over dates. Default is
             one day.
:param include: None (means no exclusion) or a function taking a
                date as parameter, and returning True if the date
                should be included.

When using mx datetime, you should *NOT* use incmonth argument, use instead
oneDay, oneHour, oneMinute, oneSecond, oneWeek or endOfMonth (to enumerate
months) as `incday` argument

datetime_to_seconds(date)

source code 
return the number of seconds since the begining of the day for that date
    


Variables Details

FRENCH_FIXED_HOLIDAYS

Value:
{'jour_an': '%s-01-01', 'fete_travail': '%s-05-01', 'armistice1945': '\
%s-05-08', 'fete_nat': '%s-07-14', 'assomption': '%s-08-15', 'toussain\
t': '%s-11-01', 'armistice1918': '%s-11-11', 'noel': '%s-12-25',}

FRENCH_MOBILE_HOLIDAYS

Value:
{'paques2004': '2004-04-12', 'ascension2004': '2004-05-20', 'pentecote\
2004': '2004-05-31', 'paques2005': '2005-03-28', 'ascension2005': '200\
5-05-05', 'pentecote2005': '2005-05-16', 'paques2006': '2006-04-17', '\
ascension2006': '2006-05-25', 'pentecote2006': '2006-06-05', 'paques20\
07': '2007-04-09', 'ascension2007': '2007-05-17', 'pentecote2007': '20\
07-05-28', 'paques2008': '2008-03-24', 'ascension2008': '2008-05-01', \
'pentecote2008': '2008-05-12', 'paques2009': '2009-04-13', 'ascension2\
009': '2009-05-21', 'pentecote2009': '2009-06-01', 'paques2010': '2010\
...