I am replacing moment by date-fns and I have this
start: moment().startOf('year').locale(this.$i18n.locale).toDate(),
end: moment().endOf('year').locale(this.$i18n.locale).toDate(),
my first thought was to do this, to keep using this.$i18n.locale
start: localYearStart(this.$i18n.locale),
end: localYearEnd(this.$i18n.locale),
export const localYearStart = (localDate) => {
const localTimeZone = getLocalTimeZone(localDate);
const formattedLocalDate = format(new Date(), 'PPpp', {locale:localTimeZone, weekStartsOn:monday});
return startOfYear(new Date(formattedLocalDate))
}
but if I use the following function, I get the same result
export const firstDayOfCurrentYear = () => {
return startOfYear(NEW_DATE);
}
My concert is. Should I use the first function or go for the second one. This is my first job as a frontend junior, as well my first and half month and my first task, so I would like to do not mess up anything. :)