Skip to content

Instantly share code, notes, and snippets.

@chrismeyersfsu
Created October 13, 2022 16:14
Show Gist options
  • Save chrismeyersfsu/663e5fbcbf9bc6ae785ad33f52ee267d to your computer and use it in GitHub Desktop.
Save chrismeyersfsu/663e5fbcbf9bc6ae785ad33f52ee267d to your computer and use it in GitHub Desktop.
timestamp to datetime. Timezone aware vs. nieve
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