Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Owo Sugiana
/
opensipkd-hitung
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 8110854e
authored
Dec 03, 2020
by
Owo Sugiana
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Bug fixed timestamp with time zone
1 parent
0fe01e9e
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
opensipkd/waktu.py
test/zona_waktu.py
opensipkd/waktu.py
View file @
8110854
...
...
@@ -18,8 +18,8 @@ def get_timezone():
def
create_datetime
(
year
,
month
,
day
,
hour
=
0
,
minute
=
7
,
second
=
0
,
microsecond
=
0
):
tz
=
get_timezone
()
return
datetime
(
year
,
month
,
day
,
hour
,
minute
,
second
,
microsecond
,
tzinfo
=
tz
)
without_tz
=
datetime
(
year
,
month
,
day
,
hour
,
minute
,
second
,
microsecond
)
return
tz
.
localize
(
without_
tz
)
def
create_date
(
year
,
month
,
day
):
...
...
test/zona_waktu.py
0 → 100644
View file @
8110854
import
unittest
import
pytz
from
datetime
import
(
date
,
datetime
,
)
from
opensipkd.waktu
import
create_datetime
class
ZonaWaktu
(
unittest
.
TestCase
):
def
setUp
(
self
):
self
.
from_str
=
'2020-10-15 13:59:32,595'
def
test_to_str
(
self
):
without_tz
=
datetime
.
strptime
(
self
.
from_str
,
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S,
%
f'
)
with_tz
=
create_datetime
(
without_tz
.
year
,
without_tz
.
month
,
without_tz
.
day
,
without_tz
.
hour
,
without_tz
.
minute
,
without_tz
.
second
,
without_tz
.
microsecond
)
to_str
=
with_tz
.
strftime
(
'
%
Y-
%
m-
%
d
%
H:
%
M:
%
S,
%
f'
)
to_str
=
to_str
.
rstrip
(
'0'
)
self
.
assertEqual
(
self
.
from_str
,
to_str
)
Write
Preview
Markdown
is supported
Attach a file
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 post a comment