Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Robert Sebille
AaaaHorodatage
Commits
3e62fb44
Commit
3e62fb44
authored
Jun 06, 2018
by
Robert Sebille
Browse files
set pour l'offset utc local
parent
6daad39e
Changes
3
Hide whitespace changes
Inline
Side-by-side
ERRORLIST
View file @
3e62fb44
...
...
@@ -3,6 +3,10 @@ List errors
AaaaHorodatage
2 : utc_seconds not in range -43200 >= utc_seconds <= +50400 in _convert_utc_seconds2string
3 : range error for year, month, day, hour, minute or second input in encode
4 : missing *offset argument in set_utc_local_offset
5 : *offset must be a string or an integer in set_utc_local_offset.
6 : utc_local_offset out of rang in set_utc_local_offset.
-43200 >= *offset <= +50400 or '-12:00' >= *offset <= '+14:00'.
AaaaHorodatageTools
51 : offset UTC timestamp 1 does not match offset UTC timestamp 2 in diffTs
...
...
README.md
View file @
3e62fb44
...
...
@@ -18,7 +18,7 @@ Your local timezone is stored in _utc_local_offset_ attribute
Default is +7200 seconds, that is to say +02:00; Europe/Brussels summertime
_utc_
local_offset_ range: -43200 >= _utc_seconds_ <= +50400
You can use _get_utc_local_offset_ or _set_utc_local_offset_ public methods to get or set it
(setter is now under construction)
.
You can use _get_utc_local_offset_ or _set_utc_local_offset_ public methods to get or set it.
#### Timezones sites
Some timezones sites can help you to determine tour timezone.
...
...
aaaa/ahordat.py
View file @
3e62fb44
...
...
@@ -69,7 +69,7 @@ class AaaaHorodatage:
# méthodes
def
_utc_seconds2string
(
self
,
utc_seconds
=
0
):
if
-
43200
>=
utc_seconds
<=
+
50400
:
if
utc_seconds
<
-
43200
or
utc_seconds
>
+
50400
:
print
(
"Fatal error: utc_seconds not in range -43200 >= utc_seconds
\
<= +50400 in _utc_seconds2string"
)
sys
.
exit
(
2
)
...
...
@@ -286,7 +286,8 @@ class AaaaHorodatage:
# instance (self)
def
get_utc_local_offset
(
self
,
typ
=
""
):
"""Get the local UTC offset.
"""Get the local UTC offset set by the
set_utc_local_offset method.
Return:
- Number of seconds (default)
...
...
@@ -298,6 +299,33 @@ class AaaaHorodatage:
retour
=
self
.
_utc_seconds2string
(
self
.
utc_local_offset
)
return
retour
def
set_utc_local_offset
(
self
,
*
offset
):
"""Set the local UTC offset.
Avalaible inputs:
- Number of seconds (-43200 >= *offset <= +50400)
- String (+/-HH:MM) ("-12:00" >= *offset <= "+14:00")
"""
if
len
(
offset
)
<
1
:
print
(
"Fatal error: missing *offset argument in "
,
end
=
""
)
print
(
"set_utc_local_offset."
)
sys
.
exit
(
4
)
if
not
isinstance
(
offset
[
0
],
int
)
and
not
isinstance
(
offset
[
0
],
str
):
print
(
"Fatal error: *offset must be a string "
,
end
=
""
)
print
(
"or an integer in set_utc_local_offset."
)
sys
.
exit
(
5
)
offset_candidate
=
offset
[
0
]
if
isinstance
(
offset
[
0
],
str
):
offset_candidate
=
self
.
_utc_string2seconds
(
offset
[
0
])
if
offset_candidate
<
-
43200
or
offset_candidate
>
+
50400
:
print
(
"Fatal error: utc_local_offset out of rang in "
,
end
=
""
)
print
(
"set_utc_local_offset."
)
print
(
" -43200 >= *offset <= +50400"
)
print
(
"or '-12:00' >= *offset <= '+14:00'."
)
sys
.
exit
(
6
)
self
.
utc_local_offset
=
offset_candidate
def
encode
(
self
,
d
=
""
,
utc
=
False
):
"""Request input of seconds, minutes, hour, year, month
and day and return an AaaaHorodatage class timestamp.
...
...
@@ -481,6 +509,9 @@ if __name__ == "__main__":
print
(
AaaaHorodatage
.
get_epoch
())
k
=
AaaaHorodatage
()
k
.
set_utc_local_offset
(
"+02:00"
)
print
(
k
.
get_utc_local_offset
())
print
(
k
.
get_utc_local_offset
(
"string"
))
print
(
"
\t
UTC offset (string): "
+
k
.
get_utc_local_offset
(
"string"
))
my_k
=
k
.
encode
()
print
(
"horodatage keyboard: "
,
my_k
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment