question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`freeze_time` could accept a timezone argument

See original GitHub issue

What do you think of having freeze_time accept a timezone argument:

@freeze_time('2015-03-09 09:00:00', timezone='US/Pacific')

That would require adding pytz to the requirements, which should be fine since most Python projects have it.

Thoughts? I might develop it.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Reactions:2
  • Comments:19 (7 by maintainers)

github_iconTop GitHub Comments

9reactions
shreevatsarcommented, Aug 18, 2015

Just FYI: one can already pass freeze_time a timezone-aware datetime object:

d = datetime(2015, 8, 18, 8, 51, 50, tzinfo=pytz.timezone('America/Los_Angeles'))
with freeze_time(d):
    print datetime.now()

(prints 2015-08-18 08:51:50-08:00)

4reactions
ze-phyr-uscommented, Jan 18, 2016

@spulec That’s a shame. While it works, it’s a bit clumsy for an extremely common use case. (I, at least, have zero Python projects that can afford to ignore time zones.)

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I set or freeze time in python? - Stack Overflow
it seems like it will be more useful than pytz. from zoneinfo import ZoneInfo timeZone_AN=("America/New_York") update. If you want to get a ...
Read more >
What would happen if we abolished time zones altogether?
So a small group of academics wants to do away with time zones for good. ... argue the introduction of Universal Time could...
Read more >
pandas.DatetimeIndex.tz_localize
This method takes a time zone (tz) naive Datetime Array/Index object and makes this time zone aware. It does not move the time...
Read more >
Time - Go Packages
Package time provides functionality for measuring and displaying time. The calendrical calculations always assume a Gregorian calendar, with no leap seconds ...
Read more >
Add a Timezone to LocalDateTime with ZonedDateTime in ...
time.Clock. The now() methods in java.time all accept a Clock argument which we can use to refactor our code so it's testable. Here's ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found