Documentation de AaaaHorodatage

Classes

Classe AaaaHorodatage

class aaaa.ahordat.AaaaHorodatage(ts='')[source]

Encoding and decoding module for timestamps of AaaaHorodatage class.

Timestamp format = [0-9]+AAAAZ+/-HH:MM where [0-9]+ = the number of seconds from the epoch until the date entered, AAAA = the epoch of the timestamp, and Z+/-HH:MM the UTC offset (e.g for CEST, summertime: Z+02:00). The timezone and epoch are embedded.

Class attribute(s) - epoch: class reference year of the timestamp (only for encoding). Range: 1000 <= epoch <= 9999. Default 2000.

Several ranges and keyboard input are managed, but not exceptions.

decode(typ='string', ts='')[source]

Request an AaaaHorodatage class timestamp input and return year, month, day, hour, minutes, seconds and offset UTC.

Return typ = - « string »: return a string (YYYY-MM-DDTHH:MM:SS+HH:MM). Default, compliant ISO 8601. - « list »: return a list (fixed order). fixed order: year, month and day, hour, minutes, seconds, UTC. - « dict » or « dictionary »: return a dict (any order). ts = timestamp: I will use ts, self.ts will not be modified. ts = none or «  »: I will use self.ts.

encode(d='', utc=False)[source]

Request input of seconds, minutes, hour, year, month and day and return an AaaaHorodatage class timestamp.

d = - «  » or none: keyboard input. - list or tuple input, (fixed order): year, month, day, hour, minutes, seconds. - dict (any order, e.g.): seconds: minutes: hour: year: month: day:

Ranges: seconds, minutes: 0-59. hour: 0-23. year: >= epoch, month: 1-12, day: 1-28/29/30/31, exact for the month. NB: encode year > 9999 with en epoch = 1000 can causes long calculations.

self.ts will be updated.

utc: True, UTC timezone (default) | False, local timezone

classmethod get_epoch()[source]

Return the current epoch of the AaaaHorodatage class.

get_ts()[source]

Return the current timestamp

get_ts_epoch()[source]

Return the epoch of the timestamp

Don’t confuse with the class attribute epoch you can get or set with class methods get_epoch() and set_epoch(num)

get_utc_local_offset(typ='')[source]

Get the local UTC offset set by the set_utc_local_offset method.

Return: - Number of seconds (default) - String (+/-HH:MM) if typ = « string »

offset_seconds2string(offset_seconds=0)[source]

Return a string, timezone offset in the form +/-HH:MM

utc_seconds = number of seconds, integer. -43200 >= utc_seconds <= +50400

offset_string2seconds(offset_string='+00:00')[source]

Return a number of seconds (integer)

utc_string: timezone offset in the form +/-HH:MM

classmethod set_epoch(num)[source]

Set the epoch of the AaaaHorodatage class.

Range: 1000 <= epoch <= 9999. Default 2000. epoch class attribute is only for encoding. For decoding, the timestamps embed their own epoch.

classmethod set_utc_local_offset(*offset)[source]

Set the local UTC offset.

Avalaible inputs: - Number of seconds (-43200 >= *offset <= +50400) - String (+/-HH:MM) (« -12:00 » >= *offset <= « +14:00 »)

update self.utc_local_offset, but !!! NOT self.ts !!! To update self.ts with the self.new utc_local_offset, you must re-encode the date

tz2utc()[source]

Convert the timestamp ts to an UTC.

self.ts will be updated.

utc2tz(*new_offset)[source]

Convert a timestamp UTC to an other timezone.

*new_offset: - Number of seconds (-43200 >= *new_offset <= +50400) - String (+/-HH:MM) (« -12:00 » >= *new_offset <= « +14:00 »)

self.ts will be updated.

Classe AaaaHorodatageTools

class aaaa.ahordat.AaaaHorodatageTools(ts='')[source]

Tools for timestamps of AaaaHorodatage class, Child class of AaaaHorodatage.

Timestamp format = [0-9]+AAAAZ+/-HH:MM where [0-9]+ = the number of seconds from the epoch until the date entered, AAAA = the epoch of the timestamp, and Z+/-HH:MM the UTC offset (e.g for CEST, summertime: Z+02:00). The timezone and epoch are embedded.

Class attribute(s) - epoch: class reference year of the timestamp (only for encoding). Range: 1000 <= epoch <= 9999. Default 2000.

Several ranges and keyboard input are managed, but not exceptions.

convert2epoch(epoch)[source]

Convert an embedded epoch to an other

1000 <= epoch <= 9999 self.ts is updated

convert_aaaa2posix()[source]

Return a Posix timestamp (UTC) from an Aaaa timestamp

convert_posix2aaaa(posix_ts)[source]

Return an Aaaa timestamp from a Posix timestamp self.ts is updated

posix_ts will be considered at UTC time.

decode(typ='string', ts='')

Request an AaaaHorodatage class timestamp input and return year, month, day, hour, minutes, seconds and offset UTC.

Return typ = - « string »: return a string (YYYY-MM-DDTHH:MM:SS+HH:MM). Default, compliant ISO 8601. - « list »: return a list (fixed order). fixed order: year, month and day, hour, minutes, seconds, UTC. - « dict » or « dictionary »: return a dict (any order). ts = timestamp: I will use ts, self.ts will not be modified. ts = none or «  »: I will use self.ts.

dhms2seconds(d=0, h=0, m=0, s=0)[source]

Convert days + hours + minutes + seconds in seconds

diffDays(typ='string', ts2=0)[source]

Difference between 2 timestamps in days, hours, minutes, seconds. ts2 - self.ts1.

Usage: ts1_object.diffDays(<typ>, <ts2>) Offset UTC timestamp 1 must match offset UTC timestamp 2 and epoch timestamp 1 must match epoch timestamp 2.

Return typ = - « seconds »: return the number of seconds. - « string »: return a string (+/-DDTHH:MM:SS). Default. - « list »: return a list (fixed order). fixed order: sens_difference, day, hour, minutes, seconds. - « dict » or « dictionary »: return a dict (any order). ts2 = 0 or none: keyboard input. ts2 eg: ts2_object.get_ts()

encode(d='', utc=False)

Request input of seconds, minutes, hour, year, month and day and return an AaaaHorodatage class timestamp.

d = - «  » or none: keyboard input. - list or tuple input, (fixed order): year, month, day, hour, minutes, seconds. - dict (any order, e.g.): seconds: minutes: hour: year: month: day:

Ranges: seconds, minutes: 0-59. hour: 0-23. year: >= epoch, month: 1-12, day: 1-28/29/30/31, exact for the month. NB: encode year > 9999 with en epoch = 1000 can causes long calculations.

self.ts will be updated.

utc: True, UTC timezone (default) | False, local timezone

classmethod get_epoch()

Return the current epoch of the AaaaHorodatage class.

get_ts()

Return the current timestamp

get_ts_epoch()

Return the epoch of the timestamp

Don’t confuse with the class attribute epoch you can get or set with class methods get_epoch() and set_epoch(num)

get_utc_local_offset(typ='')

Get the local UTC offset set by the set_utc_local_offset method.

Return: - Number of seconds (default) - String (+/-HH:MM) if typ = « string »

offset_seconds2string(offset_seconds=0)

Return a string, timezone offset in the form +/-HH:MM

utc_seconds = number of seconds, integer. -43200 >= utc_seconds <= +50400

offset_string2seconds(offset_string='+00:00')

Return a number of seconds (integer)

utc_string: timezone offset in the form +/-HH:MM

classmethod set_epoch(num)

Set the epoch of the AaaaHorodatage class.

Range: 1000 <= epoch <= 9999. Default 2000. epoch class attribute is only for encoding. For decoding, the timestamps embed their own epoch.

set_ts_same_epoch_offset(ts_object)[source]

Convert ts_object to same epoch and UTC offset than self.ts

ts_object.ts is updated

classmethod set_utc_local_offset(*offset)

Set the local UTC offset.

Avalaible inputs: - Number of seconds (-43200 >= *offset <= +50400) - String (+/-HH:MM) (« -12:00 » >= *offset <= « +14:00 »)

update self.utc_local_offset, but !!! NOT self.ts !!! To update self.ts with the self.new utc_local_offset, you must re-encode the date

tz2utc()

Convert the timestamp ts to an UTC.

self.ts will be updated.

utc2tz(*new_offset)

Convert a timestamp UTC to an other timezone.

*new_offset: - Number of seconds (-43200 >= *new_offset <= +50400) - String (+/-HH:MM) (« -12:00 » >= *new_offset <= « +14:00 »)

self.ts will be updated.