Created
October 13, 2022 16:14
-
-
Save chrismeyersfsu/663e5fbcbf9bc6ae785ad33f52ee267d to your computer and use it in GitHub Desktop.
timestamp to datetime. Timezone aware vs. nieve
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import datetime | |
def process_ts(ts, callback): | |
st = callback(ts) | |
print(st) | |
def run(): | |
def do_no_tz(ts): | |
return datetime.datetime.utcfromtimestamp(ts) | |
#return res.strftime("%m/%d/%Y, %H:%M:%S") | |
def do_strftime(ts): | |
res = datetime.datetime.utcfromtimestamp(ts) | |
return res.strftime('%b %d %Y') | |
print("Show nieve dt is bad") | |
process_ts(1609477200, do_no_tz) # Jan 1, 2021 0:00:00 | |
process_ts(1609560000, do_no_tz) # Jan 1, 2021 23:00:00 | |
print("Show https://bitbucket.org/raviolilabs/main-site/src/5bea64294ece439897d92aae3afd71a339d4c0bb/metrics/lib/CommitVolumeByPullRequest.py#lines-53") | |
process_ts(1609477200, do_strftime) # Jan 1, 2021 0:00:00 | |
process_ts(1609560000, do_strftime) # Jan 1, 2021 23:00:00 | |
run() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment