subeshb1 / Nepali-Date

📅 A small JS Library to convert English Date to Nepali and Vice Versa
https://subeshb1.github.io/Nepali-Date/
MIT License
53 stars 21 forks source link

Wrong Day Of Week #29

Closed amarbibek closed 4 years ago

amarbibek commented 4 years ago

It is giving the wrong day of the week .

let a = new NepaliDate(2077,05,08);

a.format('ddd DD, MMMM YYYY', 'np') // "बिहिबार ०८, आश्विन २०७७" <-- output

// "सोमबार ०८, भाद्र २०७७" <-- Actual Date in Nepali

issue-label-bot[bot] commented 4 years ago

Issue-Label Bot is automatically applying the label bug to this issue, with a confidence of 0.98. Please mark this comment with :thumbsup: or :thumbsdown: to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

subeshb1 commented 4 years ago

Hi @amarbibek, Sorry for the late reply.

The constructor is as follows:

NepaliDate(year: number, monthIndex: number, date: number)

You are passing in date for the month of Ashwin whose month index is 5. So, it is showing the date of next month. For Bhadra, the index is 4. The month index is expected in this constructor. This is done to make it consistent with the existing javascript Date library which uses the same approach.

Reference from the doc: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/Date

Here are the constructor docs: https://subeshb1.github.io/Nepali-Date/classes/nepalidate.html

subeshb1 commented 4 years ago

Closing this as a duplicate of https://github.com/subeshb1/Nepali-Date/issues/25

Feel free to re-open ore create another issue if your queries are not met.

amarbibek commented 4 years ago

Thanks for the response.

I could figure that out. My actual concern is the day of the week, "०८, आश्विन २०७७" was "सोमबार " not "बिहिबार".

subeshb1 commented 4 years ago

For Bhadra:

Screen Shot 2020-08-27 at 20 19 10

For Ashwin:

Screen Shot 2020-08-27 at 20 24 09

The weekday is Thursday for Ashwin 8, 2077:

Screen Shot 2020-08-27 at 20 23 05

Is it not right? Do let me know. Thanks!

@amarbibek

amarbibek commented 4 years ago

I see. It got messed up because of month. Thank you very much.