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

Result showing next day after 7PM #2

Open
Sovichetra opened this issue May 5, 2023 · 3 comments
Open

Result showing next day after 7PM #2

Sovichetra opened this issue May 5, 2023 · 3 comments

Comments

@Sovichetra
Copy link

I found one more strange
I run CLI at 5PM Local Time :

khmercal "2023-05-05T17:58:01+07:00"

Day: 1R (16 of 30)
Month: VĬSAKH
Years: 2567 B.E, 1384 J.E, 2023 C.E
Days: 384 days
Zodiac: THOS
Sequence: V បញ្ចស័ក

it's look fine but after 7PM it's showing next day:

khmercal "2023-05-05T19:58:01+07:00"

Day: 2R (17 of 30)
Month: VĬSAKH
Years: 2567 B.E, 1384 J.E, 2023 C.E
Days: 384 days
Zodiac: THOS
Sequence: V បញ្ចស័ក
@Sovichetra
Copy link
Author

By looking in the library, I see that the lunar function calculates the lunar date based on the provided date.
The function first checks if the input is a string, if it is, it converts it to a Date object. Afterwards, it subtracts 7 hours from the provided date:

if (typeof date === 'string') {  
  date = new Date(date);  
}  
date = new Date(date - 7 * 60 * 60 * 1000);

date = new Date(date - 7 * 60 * 60 * 1000);

This means if we input a date string that is after 19:00 (or 7 PM), the date will be shifted back by 7 hours, which can potentially change the date to the previous day. This is likely causing the issue of our dates after 19:00 to show as the next day in the result.

@seanghay
Copy link
Owner

seanghay commented Jun 3, 2023

@Sovichetra Can you make changes and open a pull request?

@Sovichetra
Copy link
Author

Id tried but It's seem not only that problem I trying to figure out what the real problem here but I can't find 😢

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

2 participants