Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
E
EdosL0Util
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
SIPS
EdosL0Util
Commits
20260bf5
Commit
20260bf5
authored
7 years ago
by
Bruce Flynn
Browse files
Options
Downloads
Patches
Plain Diff
fix timecode date conversion
parent
5f94b782
No related branches found
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+1
-0
1 addition, 0 deletions
.gitignore
edosl0util/timecode.py
+5
-4
5 additions, 4 deletions
edosl0util/timecode.py
setup.py
+6
-0
6 additions, 0 deletions
setup.py
tests/test_timecode.py
+29
-0
29 additions, 0 deletions
tests/test_timecode.py
with
41 additions
and
4 deletions
.gitignore
+
1
−
0
View file @
20260bf5
.eggs
.cache
build
dist
env
...
...
This diff is collapsed.
Click to expand it.
edosl0util/timecode.py
+
5
−
4
View file @
20260bf5
...
...
@@ -16,15 +16,16 @@ def unixtime(dt):
return
(
UNIX_EPOCH
-
dt
).
total_seconds
()
def
cds_to_timestamp
(
days
,
millis
,
micros
,
epoch
):
def
cds_to_timestamp
(
days
,
millis
,
micros
econds
,
epoch
):
"""
CDS to unix timestamp seconds.
"""
return
epoch
+
(
86400
*
days
)
+
(
millis
/
1000.
)
+
(
micros
/
1000000.
)
return
epoch
+
(
86400
*
days
)
+
(
millis
/
1000.
)
+
(
micros
econds
/
1000000.
)
def
cds_stamp
(
days
,
millis
,
micros
,
epoch
=
JPSS_EPOCH
):
def
cds_stamp
(
days
,
millis
,
micros
econds
,
epoch
=
JPSS_EPOCH
):
"""
CCSDS Day Segmented timecode to UTC datetime.
"""
return
JPSS_EPOCH
+
timedelta
(
days
=
days
,
microseconds
=
1000
*
millis
+
micros
)
return
epoch
+
timedelta
(
days
=
days
,
seconds
=
millis
/
1000.0
+
(
microseconds
/
1000000.
))
This diff is collapsed.
Click to expand it.
setup.py
+
6
−
0
View file @
20260bf5
...
...
@@ -15,6 +15,12 @@ setup(
install_requires
=
[
'
h5py
'
,
],
extras_require
=
{
'
testing
'
:
[
'
pytest
'
,
'
pytest-cov
'
]
},
entry_points
=
"""
[console_scripts]
edosl0split = edosl0util.cli.split:main
...
...
This diff is collapsed.
Click to expand it.
tests/test_timecode.py
0 → 100644
+
29
−
0
View file @
20260bf5
from
datetime
import
datetime
,
timedelta
from
edosl0util
import
timecode
def
test_unixtime
():
assert
timecode
.
unixtime
(
timecode
.
UNIX_EPOCH
)
==
0
def
test_cds_to_timestamp
():
epoch
=
0
secs
=
timecode
.
cds_to_timestamp
(
0
,
0
,
0
,
epoch
)
assert
secs
==
0
secs
=
timecode
.
cds_to_timestamp
(
0
,
0
,
999
,
epoch
)
assert
secs
==
0.000999
secs
=
timecode
.
cds_to_timestamp
(
1
,
1
,
999
,
epoch
)
assert
secs
==
86400.001999
def
test_cds_stamp
():
epoch
=
timecode
.
UNIX_EPOCH
assert
timecode
.
cds_stamp
(
0
,
0
,
0
,
epoch
)
==
timecode
.
UNIX_EPOCH
assert
timecode
.
cds_stamp
(
0
,
0
,
999
,
epoch
)
==
datetime
(
1970
,
1
,
1
,
0
,
0
,
0
,
999
)
assert
timecode
.
cds_stamp
(
1
,
1
,
999
,
epoch
)
==
datetime
(
1970
,
1
,
2
,
0
,
0
,
0
,
1999
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment