Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MetObsData
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
MetObs
MetObsData
Commits
e1a4000c
Commit
e1a4000c
authored
10 years ago
by
Bruce Flynn
Browse files
Options
Downloads
Patches
Plain Diff
trunc_datetime
parent
8b25b7e9
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
metobs/data/__init__.py
+1
-1
1 addition, 1 deletion
metobs/data/__init__.py
metobs/data/solar_position.py
+0
-2
0 additions, 2 deletions
metobs/data/solar_position.py
metobs/data/time.py
+14
-1
14 additions, 1 deletion
metobs/data/time.py
with
15 additions
and
4 deletions
metobs/data/__init__.py
+
1
−
1
View file @
e1a4000c
from
.time
import
to_unix_timestamp
,
hhmm_to_offset
from
.time
import
to_unix_timestamp
,
hhmm_to_offset
,
trunc_datetime
from
.units
import
*
from
.units
import
*
from
.calc
import
*
from
.calc
import
*
This diff is collapsed.
Click to expand it.
metobs/data/solar_position.py
+
0
−
2
View file @
e1a4000c
...
@@ -68,8 +68,6 @@ https://cvs.ssec.wisc.edu/cgi-bin/cvsweb.cgi/java/tower/SolarPosition.java
...
@@ -68,8 +68,6 @@ https://cvs.ssec.wisc.edu/cgi-bin/cvsweb.cgi/java/tower/SolarPosition.java
"""
"""
__docformat__
=
'
restructuredtext en
'
__docformat__
=
'
restructuredtext en
'
__version__
=
'
$Revision: 1.6 $
'
# $Source: /cvsroot/TOOLS/dev/metobs/python/data/metobs/data/solar_position.py,v $
from
metobs.data
import
NaN
,
util
from
metobs.data
import
NaN
,
util
import
math
import
math
...
...
This diff is collapsed.
Click to expand it.
metobs/data/time.py
+
14
−
1
View file @
e1a4000c
from
datetime
import
timedelta
from
datetime
import
timedelta
,
datetime
from
calendar
import
timegm
from
calendar
import
timegm
def
trunc_datetime
(
dt
,
interval
):
"""
Truncate a datetime to the nearest time on interval with basetime
of epoch.
>>>
v
=
trunc_datetime
(
datetime
(
2014
,
5
,
20
,
0
,
0
,
4
),
timedelta
(
seconds
=
5
)
>>>
assert
v
==
datetime
(
2014
,
5
,
20
,
0
,
0
,
0
)
>>>
v
=
trunc_datetime
(
datetime
(
2014
,
5
,
20
,
0
,
0
,
1
),
5
)
>>>
assert
v
==
datetime
(
2014
,
5
,
20
,
0
,
0
,
0
)
"""
if
not
isinstance
(
interval
,
timedelta
):
interval
=
timedelta
(
seconds
=
interval
)
utime
=
to_unix_timestamp
(
dt
)
return
datetime
.
utcfromtimestamp
(
utime
-
utime
%
interval
.
total_seconds
())
def
to_unix_timestamp
(
dtval
):
def
to_unix_timestamp
(
dtval
):
"""
Convert a datetime to a unix timestamp.
"""
Convert a datetime to a unix timestamp.
...
...
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