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

Calendar only works with referenceTime as a number #1102

Closed
mauscoelho opened this issue Oct 1, 2020 · 4 comments
Closed

Calendar only works with referenceTime as a number #1102

mauscoelho opened this issue Oct 1, 2020 · 4 comments

Comments

@mauscoelho
Copy link

Expected behavior
referenceTime should work for all the types:

referenceTime?: string | number | Date | dayjs.Dayjs | undefined,

Do not work:

dayjs(inputDate).calendar(dayjs(today))
dayjs(inputDate).calendar(dayjs(today).toDate())
dayjs(inputDate).calendar(dayjs(today).toString())

Works:

dayjs(inputDate).calendar(dayjs(today).date())

dayjs: "^1.9.1",

@iamkun
Copy link
Owner

iamkun commented Oct 2, 2020

Yes, referenceTime should work for all the types that dayjs() support.

Can you provide a demo code that does not work, please?

@mauscoelho
Copy link
Author

Creating the demo code I realised that the 2 dates need to be the same format.

where today = 10-02-2020 and inputDateNumber = 1601570769889

that's why in this case works 👍

dayjs(inputDateNumber).calendar(dayjs(today).date())

@iamkun
Copy link
Owner

iamkun commented Oct 2, 2020

What I can tell is . calendar accept anything that dayjs support. It does need to be the same format as the called instance.

@mauscoelho
Copy link
Author

Thanks, I didn't know that I need to use customParseFormat to parse a string, so my ref was null. This was my mistake, after using the plugin it works as expected.

Thanks

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