import d3 from 'd3' ; import { getTimezoneOffsetInMs } from './get_timezone_offset_in_ms' ; import { IUiSettingsClient } from '../../../../../../../../src/core/public' ; import { UI_SETTINGS } from '../../../../../../../../src/plugins/data/common' ; interface Params { domain : [ number , number ] ; totalTicks : number ; width : number ; } export const getTimeTicksTZ = ( { domain , totalTicks , width } ) => d3 . time . scale . utc ( ) . domain ( domain ) . range ( [ 0 , width ] ) . ticks ( totalTicks ) . map ( ( x ) => { const time = x . getTime ( ) ; return new Date ( time + getTimezoneOffsetInMs ( time ) ) ; } ) ; export const getDomainTZ = ( min , max ) : [ number , number ] => { const [ xMinZone , xMaxZone ] = [ min , max ] . map ( ( time ) => time - getTimezoneOffsetInMs ( time ) ) ; return [ xMinZone , xMaxZone ] ; } ; export function getTimeZone ( uiSettings ? ) { const kibanaTimeZone = uiSettings ?. get < 'Browser' | string > ( UI_SETTINGS . DATEFORMAT_TZ ) ; if ( ! kibanaTimeZone || kibanaTimeZone === 'Browser' ) { return 'local' ; } return kibanaTimeZone ; }