-
Notifications
You must be signed in to change notification settings - Fork 15
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
RangeError: Missing relativeTo #29
Comments
Off-topic, for second example, I just realized I get the same with const { weeks } = getStartOfWeek(date).since(
getStartOfWeek(referenceDate),
{ largestUnit: "weeks" },
); |
Hi @steida , that is part of the spec and is expected behavior... Temporal works with a number of different calendar systems (not just the Gregorian one that you and I are used to), so it requires a little more work. A const epoch = Temporal.PlainDate.from("1970-01-01");
const value = Temporal.Now.plainDateISO();
const monthsSinceEpoch = value.since(epoch).total({ unit: 'months', relativeTo: epoch }); |
If you'd like to round it to a whole-number right away, you can do this instead: const integerMonthsSinceEpoch = value.since(epoch, {
largestUnit: 'month',
smallestUnit: 'month'
}).months |
Thank you! Am I correct that with const { weeks } = getStartOfWeek(date).since(getStartOfWeek(epoch), {
largestUnit: "weeks",
// smallestUnit: "weeks",
}); |
If the Just curious, where is this |
Is this code wrong?
Another example:
Btw, thank you for the awesome lib!
The text was updated successfully, but these errors were encountered: