gastromatic / calendar-date

Immutable object to represent and work with a calendar date with zero dependencies
MIT License
21 stars 1 forks source link

Using weekday seems to give incorrect results. #210

Closed scottbeaumont closed 1 year ago

scottbeaumont commented 1 year ago

According to the documentation found here, I expect the following test should pass since January 1st, 2023 is a Sunday.

test('simple calendar test', () => {
     expect(new CalendarDate(`2023-01-01`).weekday).toBe(7)
})

Unfortunately, it fails with

simple calendar test
expect(received).toBe(expected) // Object.is equality
    Expected: 7
    Received: 6

Am I missing something, or is this unexpected?

co-sic commented 1 year ago

Hey @scottbeaumont thank you for reporting this issue! I just tested it, and this is a bug in the constructor. Your current timezone is affecting the weekday, that is why it is working for me (Europe timezone) and not for you (I guess you are in the USA?). I will fix this as soon as possible and get back to you!

co-sic commented 1 year ago

@scottbeaumont solved in #212

scottbeaumont commented 1 year ago

@co-sic Thanks for resolving and thanks for the package. It's appreciated.