I have a quite data-heavy app I'm working on, and I can see in Chrome's profiler that moment
is chewing up an enormous amount of CPU when working with large datasets. I'm aware it's reasonably well-known for this, but I don't know how I'd format timezones with a native Date
object. Is it achievable?
For what it's worth, the super expensive function I've written is this:
export const formatByTimeZone = date => {
const userTimezone = moment.tz.guess()
moment.tz.setDefault('Australia/Melbourne')
const returnValue = moment(date).tz(userTimezone)
moment.tz.setDefault()
return returnValue
}
Our API uses Melbourne time, so it just converts that to the user's time.