top | item 33139425

(no title)

yilugurlu | 3 years ago

Having read the cookbook [1], and wow that's a complex API out there. I can see that there will be a `Temporal Light` to allow us to do `now().startOf('month')` like calls.

[1] https://tc39.es/proposal-temporal/docs/cookbook.html

discuss

order

moogly|3 years ago

Wouldn't this work?

    const firstInMonth = Temporal.Now.with({ day: 1 });

chrismorgan|3 years ago

Correction:

  Temporal.Now.plainDateISO().with({ day: 1 })
Today (2022-10-10 on my computer), that’ll get you a PlainDate representing 2022-10-01.

The “ISO” in there identifies the calendar. Want to know what the first of the current month in the Hebrew calendar is?

  Temporal.Now.plainDate("hebrew").with({ day: 1 })
And that gives you 2022-09-26[u-ca=hebrew].