spencermountain / spacetime

A lightweight javascript timezone library
http://spacetime.how/
Other
3.97k stars 184 forks source link

week function not working correctly #386

Open ChrisSeakane opened 1 year ago

ChrisSeakane commented 1 year ago

Seems like 2022 starts already as week 2, and goes up to 53 and back down to 52 again

let d = spacetime('2022/01/01','utc');
d = d.every('day','2022/12/31');
d.forEach(function (e) {console.log(e.format('iso-short'),e.week())})

2022-01-01 2 2022-01-02 2 2022-01-03 3 2022-01-04 3 2022-01-05 3 2022-01-06 3 2022-01-07 3 2022-01-08 3 2022-01-09 3 2022-01-10 4 2022-01-11 4 2022-01-12 4 . . . 2022-12-10 51 2022-12-11 51 2022-12-12 52 2022-12-13 52 2022-12-14 52 2022-12-15 52 2022-12-16 52 2022-12-17 52 2022-12-18 52 2022-12-19 53 2022-12-20 53 2022-12-21 53 2022-12-22 53 2022-12-23 53 2022-12-24 53 2022-12-25 53 2022-12-26 52 2022-12-27 52 2022-12-28 52 2022-12-29 52 2022-12-30 52

spencermountain commented 1 year ago

Thanks chris. Yep, this looks like an issue. will check it out today cheers

spencermountain commented 1 year ago

argh - gonna move this behind 8.0. Redoing this logic anyways. Let me know if it's a serious problem, and I can do a hotfix. thanks

ChrisSeakane commented 1 year ago

No worries. Take your time.

DarshanDixit05 commented 1 year ago

Hi 👋, I wanted to work on this issue . Can you please assign it to me?

spencermountain commented 1 year ago

it's all yours! the issue is in here where the week-adding logic is scrambled-up. Feel free to change anything! It's pretty gross, as it is. cheers

DarshanDixit05 commented 1 year ago

Hello, Can you tell me how to reproduce this issue? And preview my changes?

On Sat, 6 May 2023 at 20:51, spencer kelly @.***> wrote:

it's all yours! the issue is in here https://github.com/spencermountain/spacetime/blob/master/src/methods/query/03-year.js#L70 where the week-adding logic is scrambled-up. Feel free to change anything! It's pretty gross, as it is. cheers

— Reply to this email directly, view it on GitHub https://github.com/spencermountain/spacetime/issues/386#issuecomment-1537163803, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASKPO4NMPLHFGFDLYILFDJTXEZT77ANCNFSM6AAAAAAXBRKIKU . You are receiving this because you were assigned.Message ID: @.***>

spencermountain commented 1 year ago

hi Darshan, you can clone the repo and run Chris's example from above. I like to use the ./scratch.js file - i have it setup to hot-reload using npm run watch

  1. git clone
  2. npm install
  3. put chris's example in ./scratch.js
  4. npm run watch
DarshanDixit05 commented 1 year ago

Hey @spencermountain 👋, The test case @ChrisSeakane mentioned is fixed. I think the logic written to check whether we're going to last year or not had some conditional check errors.