Module gmDateTime
source code
GNUmed date/time handling.
This modules provides access to date/time handling
and offers an fuzzy timestamp implementation
It utilizes
- Python time
- Python datetime
- mxDateTime
Note that if you want locale-aware formatting you need to call
locale.setlocale(locale.LC_ALL, '')
somewhere before importing this script.
Note regarding UTC offsets
--------------------------
Looking from Greenwich:
WEST (IOW "behind"): negative values
EAST (IOW "ahead"): positive values
This is in compliance with what datetime.tzinfo.utcoffset()
does but NOT what time.altzone/time.timezone do !
This module also implements a class which allows the
programmer to define the degree of fuzziness, uncertainty
or imprecision of the timestamp contained within.
This is useful in fields such as medicine where only partial
timestamps may be known for certain events.
Version:
$Revision: 1.34 $
Author:
K. Hilbert <Karsten.Hilbert@gmx.net>
License:
GPL (details at http://www.gnu.org)
|
|
|
|
|
pydt_now_here()
Returns NOW @ HERE (IOW, in the local timezone. |
source code
|
|
|
|
|
wx_now_here(wx=None)
Returns NOW @ HERE (IOW, in the local timezone. |
source code
|
|
|
|
|
|
|
format_interval(interval=None,
accuracy_wanted=7) |
source code
|
|
|
|
|
calculate_apparent_age(start=None,
end=None)
The result of this is a tuple (years, ..., seconds) as one would
'expect' a date to look like, that is, simple differences between the
fields. |
source code
|
|
|
format_apparent_age_medically(age=None)
<age> must be a tuple as created by calculate_apparent_age() |
source code
|
|
|
|
|
str2pydt_matches(str2parse=None,
patterns=None)
Turn a string into candidate dates and auto-completions the user is
likely to type. |
source code
|
|
|
|
|
__doc__ = ...
|
|
dst_locally_in_use = None
|
|
dst_currently_in_effect = None
|
|
current_local_utc_offset_in_seconds = None
|
|
current_local_timezone_interval = None
|
|
current_local_iso_numeric_timezone_string = None
|
|
current_local_timezone_name = None
|
|
py_timezone_name = None
|
|
py_dst_timezone_name = None
|
|
gmCurrentLocalTimezone = ' gmCurrentLocalTimezone not initialized '
|
|
gregorian_month_length = { 1: 31, 2: 28, 3: 31, 4: 30, 5: 31, 6...
|
|
avg_days_per_gregorian_year = 365
|
|
avg_days_per_gregorian_month = 30
|
|
avg_seconds_per_day = 86400
|
|
days_per_week = 7
|
|
acc_days = 4
|
|
acc_hours = 5
|
|
acc_minutes = 6
|
|
acc_months = 2
|
|
acc_seconds = 7
|
|
acc_subseconds = 8
|
|
acc_weeks = 3
|
|
acc_years = 1
|
Imports:
sys,
pyDT,
time,
os,
regex,
locale,
logging,
mxDT,
psycopg2,
gmI18N,
cLocalTimezone,
cFixedOffsetTimezone
Formats an interval.
This isn't mathematically correct but close enough for display.
|
calculate_apparent_age(start=None,
end=None)
| source code
|
The result of this is a tuple (years, ..., seconds) as one would
'expect' a date to look like, that is, simple differences between the
fields.
No need for 100/400 years leap days rule because 2000 WAS a
leap year.
This does not take into account time zones which may shift the result
by one day.
<start> and <end> must by python datetime instances
<end> is assumed to be "now" if not given
|
str2pydt_matches(str2parse=None,
patterns=None)
| source code
|
Turn a string into candidate dates and auto-completions the user is
likely to type.
You MUST have called locale.setlocale(locale.LC_ALL, '') somewhere in
your code previously.
- Parameters:
patterns (list) - list of time.strptime compatible date pattern
|
str2fuzzy_timestamp_matches(str2parse=None,
default_time=None,
patterns=None)
| source code
|
Turn a string into candidate fuzzy timestamps and auto-completions the
user is likely to type.
You MUST have called locale.setlocale(locale.LC_ALL, '') somewhere in
your code previously.
- Parameters:
default_time (an mx.DateTime.DateTimeDelta instance) - if you want to force the time part of the time stamp to a given
value and the user doesn't type any time part this value will be
used
patterns (list) - list of [time.strptime compatible date/time pattern, accuracy]
|
__doc__
- Value:
"""
GNUmed date/time handling.
This modules provides access to date/time handling
and offers an fuzzy timestamp implementation
It utilizes
...
|
|
gregorian_month_length
- Value:
{ 1: 31,
2: 28,
3: 31,
4: 30,
5: 31,
6: 30,
7: 31,
8: 31,
...
|
|