This program is under GNU General Public License, version 3, see LICENCE text file.<br/>
This program needs python 3 and modules datetime, aaaa.ahordat, aaaa.ahordattools. _The datetime module is used only to get the server's utc local offset, outside the scope of this project._
This program needs python 3 and modules aaaa.ahordat, aaaa.ahordattools.
__Below, in the same directory as this README file__
## AaaaHorodatage 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.
__Below, in the same directory as this README.md file__
## Usage
### In a file.py:
from aaaa.ahordattools import AaaaHorodatageTools
...
...
@@ -13,6 +16,15 @@ __Below, in the same directory as this README file__
>>> <new instance> = AaaaHorodatageTools()
>>> <your code>
### Generate timestamps
encode(d="", utc=False) # possible inputs:
d="": keyboard input
d= list, tuple or dictionary.
utc=False: Local UTC offset encoding (see "Setting your timezone")
utc=True: UTC encoding
decode("typ", ts) typ = "string", "list", "dict" ou "dictionary"
## Timezones
### Setting your timezone
Your local timezone is stored in _utc_local_offset_ attribute
You can use this methods to convert offset from seconds to string and from string to seconds.
...
...
@@ -45,21 +56,38 @@ Some timezones sites can help you to determine tour timezone.
*[Time.is](https://time.is/time_zones)
*[Time_zone](https://en.wikipedia.org/wiki/Time_zone) on Wikipedia.
## Reference epoch
## Epoch
the reference epoch of the AaaaHorodatage class stored in _epoch_ class attribute
Default is 1900. Range: 0 <= _epoch_ <= 9999.
Default is 2000. Range: 1000 <= _epoch_ <= 9999.
The epoch attribute is used for encoding timestamps only. For decoding, the script uses the embedded epoch. Timestamp epoch lesser than epoch class attribute are accepted on decoding.
### Setting epoch
You can use this class methods to get or set it.
get_epoch()
set_epoch(num) # 0 <= epoch <= 9999
set_epoch(num) # 1000 <= epoch <= 9999
### Converting epoch
You can change and adapt the embedded epoch of a timestamp.
convert2epoch(self, ts, epoch) # Convert an embedded epoch to an other. 1000 <= epoch <= 9999
## Operations
Operations relate to timestamps of the same UTC offset and at the same epoch only.
Please, be consistent with yourself! e.g., you must encode and decode the same timestamp with the same epoch; or the results will be incoherent. It's why this method is a class method.
Remember this: The only way to know what is the reference epoch of a time stamp, is to remember it.