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
2aa698f3
Commit
2aa698f3
authored
6 years ago
by
Bruce Flynn
Browse files
Options
Downloads
Patches
Plain Diff
lazy load grain
parent
3c6aa12d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
edosl0util/timecode.py
+17
-5
17 additions, 5 deletions
edosl0util/timecode.py
with
17 additions
and
5 deletions
edosl0util/timecode.py
+
17
−
5
View file @
2aa698f3
...
...
@@ -8,8 +8,6 @@ __copyright__ = "Copyright (C) 2015 University of Wisconsin SSEC. All rights res
UNIX_EPOCH
=
datetime
(
1970
,
1
,
1
)
CDS_EPOCH
=
datetime
(
1958
,
1
,
1
)
_grain
=
Grain
()
def
unixtime
(
dt
):
"""
...
...
@@ -29,7 +27,7 @@ def timecode_parts_to_iet(days, ms, us, epoch):
"""
Convert components to a IET based on arbitrary epoch.
"""
return
int
(
_grain
.
utc2tai
(
return
int
(
_
get_
grain
()
.
utc2tai
(
epoch
+
timedelta
(
days
=
float
(
days
),
milliseconds
=
float
(
ms
),
microseconds
=
float
(
us
)),
...
...
@@ -58,5 +56,19 @@ def dt_to_cds(dt):
return
(
d
.
days
,
int
(
d
.
seconds
*
1e3
),
d
.
microseconds
)
dt_to_iet
=
_grain
.
utc2iet
iet_to_dt
=
_grain
.
iet2utc
_grain
=
None
def
_get_grain
():
global
_grain
if
_grain
is
None
:
_grain
=
Grain
()
return
_grain
def
dt_to_iet
(
*
args
,
**
kwargs
):
return
_get_grain
().
utc2iet
(
*
args
,
**
kwargs
)
def
iet_to_dt
(
*
args
,
**
kwargs
):
return
_get_grain
().
iet2utc
(
*
args
,
**
kwargs
)
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