Commit 5e0387c7 authored by Robert Sebille's avatar Robert Sebille
Browse files

Fin des tests pour pip. Publication

parent 97d70c42
[file_prefs]
final_new_line=true
ensure_convert_new_lines=false
strip_trailing_spaces=false
replace_tabs=true
[indentation]
indent_width=4
indent_type=0
indent_hard_tab_width=8
detect_indent=false
detect_indent_width=false
indent_mode=2
[project]
name=AaaaHorodatage
base_path=/home/robert/dev/python/AaaaHorodatage
[long line marker]
long_line_behaviour=1
long_line_column=80
[files]
current_page=0
[VTE]
last_dir=/home/robert/Nextcloud/dev/python/puissance4
......@@ -217,5 +217,5 @@ Consider this tips:
python3 main.py
__You can find some thoughts about algorithms in this [pdf document](https://bit.ly/2seHHvU "Horodatage").__
__You can find some thoughts about algorithms in this [pdf document](https://bit.ly/2seHHvU "Horodatage").__ This is not a documentation book, just a few thoughts.
......@@ -26,10 +26,10 @@
# https://www.python.org/dev/peps/pep-0008/ #
#############################################
import os
import sys
import math
import time
import os.path as p
class AaaaHorodatage:
......@@ -51,12 +51,13 @@ class AaaaHorodatage:
# année de référence (attribut de classe)
epoch = 2000
# Europe/Brussels summertime
# Europe/Brussels summertime
utc_local_offset = 7200
def __init__(self, ts=""):
# protected
# Liste nombre de jours par mois, moins décembre et année non bissextile
# Liste nombre de jours par mois, moins décembre et année non
# bissextile
self._ljm = (31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31)
self._nb_sec_par_jour = 86400
# public
......@@ -125,7 +126,8 @@ class AaaaHorodatage:
print("I want an integer, please: ", end="")
ok = False
def _calcul_encode(self, annee, mois, jour, heures, minutes, secondes, utc):
def _calcul_encode(self, annee, mois, jour, heures, minutes, secondes,
utc):
"""Encode the timestamp."""
# ts = horodatage
ts = secondes
......@@ -302,11 +304,11 @@ class AaaaHorodatage:
- Number of seconds (-43200 >= *offset <= +50400)
- String (+/-HH:MM) ("-12:00" >= *offset <= "+14:00")
update self.utc_local_offset, but /!\ NOT self.ts /!\\
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
"""
if len(offset) < 1:
print("Fatal error 4: missing *offset argument in ", end="")
print("set_utc_local_offset(*offset).")
......@@ -516,7 +518,7 @@ class AaaaHorodatage:
"""
ts = self.ts
ts_list = self.decode("list", ts)
# ts_list = self.decode("list", ts)
# ts_tmp_list[3] = heure, ts_tmp_list[4] = minutes
tmp = ts.split("Z")
ts_sec = int(tmp[0])
......@@ -579,60 +581,8 @@ class AaaaHorodatage:
return self.ts
if __name__ == "__main__":
# Pour tester le module ...
s = 12
m = 2
h = 12
A = 2000
M = 2
J = 29
epo = 1900
print("(NB: If you enter " + str(J) + "/" + str(M) + "/" + str(A) + " " +
str(h) + ":" + str(m) + ":" + str(s) +
", you will obtain 4 same results)")
print("Keyboard, tuple, list end dict")
# AaaaHorodatage.set_epoch(epo)
print(AaaaHorodatage.get_epoch())
k = AaaaHorodatage()
k.set_utc_local_offset("+02:00")
# date_test = [2000, 12, 31, 23, 5, 0]
# date_test = [2001, 1, 1, 0, 0, 0]
date_test = [2010, 2, 3, 1, 5, 0]
# k.set_utc_local_offset("+00:00")
print(date_test)
myK = k.encode(date_test)
print("myK ", myK)
# myKTrue = k.encode(date_test, True)
myKTrue = k.tz2utc(myK)
print("myKTrue ", myKTrue)
print("MyKtrue to tz ", k.utc2tz(myKTrue, k.get_utc_local_offset()))
print("myK ", k.decode("string", myK))
print("myKTrue ", k.decode("string", myKTrue))
print("myKTrue ", k.decode("list", myKTrue))
print("myKTrue ", k.decode("dict", myKTrue))
print(k.get_utc_local_offset())
print(k.get_utc_local_offset("string"))
print("\tUTC offset (string): " + k.get_utc_local_offset("string"))
my_k = k.encode()
print("horodatage keyboard: ", my_k)
t = AaaaHorodatage()
print("horodatage tuple : ", t.encode((A, M, J, h, m, s)))
l = AaaaHorodatage()
print("horodatage list : ", l.encode([A, M, J, h, m, s]))
dic0 = {"seconds": s, "minutes": m, "hour": h, "year": A, "month": M,
"day": J}
d = AaaaHorodatage()
print("horodatage dict : ", d.encode(dic0))
print("1: ", k.decode())
print("2: ", k.decode("dictionary"))
print("3: ", l.decode("dictionary", my_k))
chemin = p.dirname(p.abspath(__file__)) + "/"
class AaaaHorodatageTools(AaaaHorodatage):
......@@ -655,24 +605,24 @@ class AaaaHorodatageTools(AaaaHorodatage):
# For dev start #
# in AaaaHorodatage:
# année de référence (attribut de classe)
# année de référence (attribut de classe)
# epoch = 1900
# private
# attributs
# attributs
# def _get_ljm(self, i):
# ljm = property(_get_ljm)
# methodes
# methodes
# def _bissextile(self, an = 0):
# def _input_entier(self, annonce=""):
# def _calcul_encode(self):
# def _cal def _input_entier(self, annonce=""):cul_decode(self, typ):
# méthodes publiques
# classe (cls)
# classe (cls)
# def get_epoch(cls):
# get_epoch = classmethod(get_epoch)
# def set_epoch(cls, num):
# set_epoch = classmethod(set_epoch)
# instance (self)
# instance (self)
# def encode(self, d=""):
# def decode(self, typ="string", t=0):
# For dev end
......@@ -680,12 +630,12 @@ class AaaaHorodatageTools(AaaaHorodatage):
def __init__(self, ts=""):
AaaaHorodatage.__init__(self, ts)
# protected
#douglas = open("aaaa/42", "r")
#self._Aaaa42 = douglas.read()
#douglas.close()
# douglas = open("aaaa/42", "r")
# self._Aaaa42 = douglas.read()
# douglas.close()
def get_42(self):
douglas = open("aaaa/42", "r")
douglas = open(chemin + "42", "r")
print(douglas.read())
douglas.close()
print("Non fatal error 42: existential error 101010.")
......@@ -701,7 +651,7 @@ class AaaaHorodatageTools(AaaaHorodatage):
print("|101010 101010 101010 101010 101010 101010 101010 101010 101010\
101010 101010 |\n")
#get_42 = property(_get_42)
# get_42 = property(_get_42)
# protected #
# attributs
......@@ -814,7 +764,8 @@ class AaaaHorodatageTools(AaaaHorodatage):
if ts_seconds >= seconds:
ts_seconds -= seconds
else:
print("Fatal error 53: number of seconds to substract ", end="")
print("Fatal error 53: number of seconds to substract ",
end="")
print("to big in __sub__(seconds=0). Substract < ", end="")
print(ts_epoch, "-01-01 (epoch of the timestamp)", sep="")
print("Program halted.")
......@@ -946,7 +897,7 @@ class AaaaHorodatageTools(AaaaHorodatage):
aaaa_ts = self.copy()
aaaa_ts.convert2epoch(1970)
aaaa_ts.tz2utc()
#self.ts = save_local_ts
# self.ts = save_local_ts
tmp = aaaa_ts.get_ts().split("Z")
ts_sec = int(tmp[0])
ts_sec = int(ts_sec / 10000)
......@@ -979,6 +930,7 @@ class AaaaHorodatageTools(AaaaHorodatage):
return ts_object
if __name__ == "__main__":
# at top, # from ahordat import AaaaHorodatage # to test module
......
......@@ -29,6 +29,7 @@ def input_entier(annonce=""):
print("An integer, please: ", end="")
ok = False
def demo():
print("+------+\n| DEMO |\n+------+\n")
......@@ -60,7 +61,7 @@ def demo():
rep = False
print("+-----------------------------+")
#del myDTutc
# del myDTutc
myDTutc = myDT.copy()
myDTutc.encode(date_test, True)
print("Encode date test (direct to UTC): ", myDTutc)
......@@ -121,8 +122,8 @@ def demo():
myDT.decode())
myDT1900 = AaaaHorodatageTools()
myDT1900.encode(date_test)
print("Encoding with epoch 1900: ", myDT1900.get_ts(), " = ",
myDT1900.decode())
print("Encoding with epoch 1900: ", myDT1900.get_ts(),
" = ", myDT1900.decode())
myDT1900.set_epoch(2000)
print("Reset epoch to 2000: ", myDT1900.get_epoch())
print("Get current embedded epoch of date test: ", myDT1900.get_ts_epoch())
......@@ -179,6 +180,7 @@ def demo():
print("\n+-------------+\n| Goodbye ... |\n+-------------+\n")
if __name__ == '__main__':
demo()
pass
......@@ -5,7 +5,7 @@ with open("README.md", "r") as fh:
setuptools.setup(
name="aaaahorodatage",
version="0.0.1.0",
version="0.0.1",
author="Robert Sebille",
author_email="robert@sebille.name",
maintainer = 'Robert Sebille',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment