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
46184797
Commit
46184797
authored
9 years ago
by
Bruce Flynn
Browse files
Options
Downloads
Patches
Plain Diff
Ability to get unix timestamp from timecode
parent
51ea1874
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
edosl0util/headers.py
+10
-1
10 additions, 1 deletion
edosl0util/headers.py
edosl0util/timecode.py
+8
-1
8 additions, 1 deletion
edosl0util/timecode.py
with
18 additions
and
2 deletions
edosl0util/headers.py
+
10
−
1
View file @
46184797
...
...
@@ -21,7 +21,7 @@ from edos.ccsds import (
GROUP_STANDALONE
)
from
edosl0util.timecode
import
cds_stamp
from
edosl0util.timecode
import
cds_stamp
,
cds_to_timestamp
class
BaseStruct
(
c
.
BigEndianStructure
):
...
...
@@ -52,8 +52,13 @@ class AquaCucTimecode(BaseStruct):
]
EPOCH
=
datetime
(
1958
,
1
,
1
)
EPOCH_SECS
=
(
EPOCH
-
datetime
(
1970
,
1
,
1
)).
total_seconds
()
SUB_SECOND_UNITS
=
15.2
def
astimestamp
(
self
):
tc
=
self
.
timecode
return
cds_to_timestamp
(
tc
.
days
,
tc
.
milliseconds
,
tc
.
microseconds
,
self
.
EPOCH_SECS
)
def
asdatetime
(
self
):
"""
Return converted to UTC where leap seconds are as defined in `leap_seconds`.
...
...
@@ -75,6 +80,10 @@ class DaySegmentedTimecode(BaseStruct):
]
EPOCH
=
datetime
(
1958
,
1
,
1
)
EPOCH_SECS
=
(
EPOCH
-
datetime
(
1970
,
1
,
1
)).
total_seconds
()
def
astimestamp
(
self
):
return
cds_to_timestamp
(
self
.
days
,
self
.
milliseconds
,
self
.
microseconds
,
self
.
EPOCH_SECS
)
def
asdatetime
(
self
):
return
cds_stamp
(
self
.
days
,
self
.
milliseconds
,
self
.
microseconds
)
...
...
This diff is collapsed.
Click to expand it.
edosl0util/timecode.py
+
8
−
1
View file @
46184797
...
...
@@ -14,8 +14,15 @@ def unixtime(dt):
return
(
UNIX_EPOCH
-
dt
).
total_seconds
()
def
cds_to_timestamp
(
days
,
millis
,
micros
,
epoch
):
"""
CDS to unix timestamp seconds.
"""
return
epoch
+
(
86400
*
days
)
+
(
millis
/
1000.
)
+
(
micros
/
1000000
)
def
cds_stamp
(
days
,
millis
,
micros
,
epoch
=
JPSS_EPOCH
):
"""
CCSDS Day Segmented timecode to UTC datetime.
"""
return
JPSS_EPOCH
+
timedelta
(
days
=
days
,
microseconds
=
1000
*
millis
+
micros
)
\ No newline at end of file
return
JPSS_EPOCH
+
timedelta
(
days
=
days
,
microseconds
=
1000
*
millis
+
micros
)
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