In case I have a Date and I want to check if the time is DST I can use a method, such as the following:
function isDST(d) {
let jan = new Date(d.getFullYear(), 0, 1).getTimezoneOffset();
let jul = new Date(d.getFullYear(), 6, 1).getTimezoneOffset();
return Math.max(jan, jul) != d.getTimezoneOffset();
}
(source here)
In case I use MomentJS library I reach the same in this way:
moment().isDST();
Anyone knows how to do the same with the upcoming Temporal?
the temporal api has a
offsetNanosecondsread-onlypropertyalso there's the
withmethod which returns a new object with specified field being overwritten.i have to admit i haven't tested it but something like this should basically be the equivalent to your function. (month index starts at 1)
zoned DateTime
refine dev
web dev simplified