Last active
February 16, 2017 20:08
-
-
Save bryder/0918d5b2de782849cd3043d71de5849a to your computer and use it in GitHub Desktop.
Using arrow
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
# http://arrow.readthedocs.io/en/latest/ | |
# when you to('local') you are taking utc and applying the localtime offset | |
# to it - and adding the local timezone descriptor to the object | |
now = arrow.utcnow().to('local') | |
# plural means add or subtract from | |
# singular means set to | |
# nice! | |
two_days_ago_rounded = now.replace(days=-2, hour=0, minute=0, second=0, microsecond=1) | |
# Setting the timezone on a time - this does not convert it! | |
# It marks the object as being in the requested timezone. | |
two_days_ago_rounded.replace(tzinfo=tz.tzlocal()) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment