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.

is_utc() returns False when parsing from a UTC date

See original GitHub issue

This date is UTC: '2018-06-21T09:30:00+00:00', however, the is_utc() method returns False.

>>> pendulum.parse('2018-06-21T09:30:00+00:00').timezone
Timezone('+00:00')

>>> pendulum.parse('2018-06-21T09:30:00+00:00').is_utc()
False

The current implementation is:

    def is_utc(self):
        return self.timezone_name == 'UTC'

Maybe it can be something like:

    def is_utc(self):
        return self.timezone.offset == 0

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
dazza-codescommented, Nov 15, 2018

Yes, reproducing the behavior in 1.5.1 vs 2.x is important for me (and possibly others landing here).

1reaction
redlickigrzegorzcommented, Oct 27, 2018

I created a pull request #295 for resolving this issue. I hope it resolves the problem. I would like to ask for a review also.

Read more comments on GitHub >

github_iconTop Results From Across the Web

`isUtc()` does not seem to be working · Issue #3687
isUtc (); // returns false Even it is not recognizing moment generated UTC dates as UTC, see var utcDate = moment.utc().format(); ...
Read more >
moment.js - UTC does not work as i expect it
why does withMoment return the timestamp calculated from the current local-time? how can i achieve that moment.utc() returns the same as Date.
Read more >
dart/sdk/lib/core/date_time.dart - external/dart
or by parsing a correctly formatted string, ... Use [isUtc] to determine whether a DateTime object is based in UTC. ... DateTime.now() :...
Read more >
Moment.js Tutorial
Use .toDate() to convert back to a JavaScript date. Dates are interpreted as local time. Unless instantiated with moment.utc() .
Read more >
UTC
UTC adds .utc .local .isUTC APIs to parse or display in UTC. var utc = require('dayjs/plugin/utc') dayjs.extend(utc) // default local time dayjs().format() ......
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