Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

startOf always returns non utc date even if date was utc #85

Closed
NuclleaR opened this issue Dec 26, 2020 · 4 comments
Closed

startOf always returns non utc date even if date was utc #85

NuclleaR opened this issue Dec 26, 2020 · 4 comments

Comments

@NuclleaR
Copy link

Describe the bug
Jiffy(Jiffy().utc()).dateTime.isUtc returns true
Jiffy(Jiffy().utc()).startOf(Units.MONTH).isUtc returns false

Expected behavior
If date was in UTC, startOf should return UTC DateTime object

Smartphone (please complete the following information):

  • Device: iPhone12
  • OS: iOS14
@omidraha
Copy link

Jiffy(Jiffy().utc()).startOf(Units.DAY).dateTime.toUtc();

@RobertHeim
Copy link

RobertHeim commented Oct 29, 2021

The problem I see is that we cannot get the start/end in a specific timezone. It always uses the local timezone.

Jiffy(DateTime.now().toUtc()).startOf(Units.MONTH).utc();
// actually: 2021-09-30 22:00:00.000Z
// expected: 2021-10-01 00:00:00.000Z

@mindfaq13
Copy link

any news on this one ?

I chose Jiffy for date-time manipulation since it promises to make tasks like date/time diff calculation easier. Dart's built-in DateTime only allows expressing time difference in milliseconds, seconds all the way up to days - but no months or years since these two are a bit tricky to get right.
I thought Jiffy would make for a good DateTime replacement, but startOf / endOf methods as of now are pretty much useless if you try to manipulate UTC timestamps, so I'm forced to look for an alternative.
Or maybe there is an obvious workaround I fail to see ?

@RobertHeim
Copy link

RobertHeim commented Mar 8, 2022

well I think strictly speaking UTC is not a time zone, but we need a time zone to calculate startOf / endOf. I guess most people expect that the calculation for a UTC DateTime should be done in time zone GMT and not in the local time zone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants