Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
b39aff87
Commit
b39aff87
authored
Jun 09, 1999
by
Guido van Rossum
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add unrelated but handy function: timegm(), to calculate Unix
timestamp from GMT tuple.
parent
145a5f73
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
Lib/calendar.py
Lib/calendar.py
+17
-0
No files found.
Lib/calendar.py
View file @
b39aff87
...
...
@@ -151,3 +151,20 @@ def prcal(year):
prweek
(
cal
[
i
],
2
)
print
_spacing
,
print
# Unrelated but handy function to calculate Unix timestamp from GMT
EPOCH
=
1970
def
timegm
(
tuple
):
year
,
month
,
day
,
hour
,
minute
,
second
=
tuple
[:
6
]
assert
year
>=
EPOCH
assert
1
<=
month
<=
12
days
=
365
*
(
year
-
EPOCH
)
+
leapdays
(
EPOCH
,
year
)
for
i
in
range
(
1
,
month
):
days
=
days
+
mdays
[
i
]
if
month
>
2
and
isleap
(
year
):
days
=
days
+
1
days
=
days
+
day
-
1
hours
=
days
*
24
+
hour
minutes
=
hours
*
60
+
minute
seconds
=
minutes
*
60
+
second
return
seconds
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
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 comment