Created
October 19, 2020 12:34
-
-
Save capaj/2435a3e0615987b9165e26c561626382 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import moment from 'moment-timezone' | |
export const shiftUtcDayTimeToTimezone = ( | |
utcDayTime: string, | |
timezone: string | |
) => { | |
const offsetMinutes = moment.tz(moment.utc(), timezone).utcOffset() | |
const [hours, minutes] = utcDayTime.split(':') | |
const quotient = Math.floor(offsetMinutes / 60) | |
const remainder = offsetMinutes % 60 | |
return `${Number(hours) + quotient}:${Number(minutes) + remainder}` | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment