@@ -195,7 +195,7 @@ export const BUILD_RANGE_END_LOCAL = '__BUILD_RANGE_END_LOCAL';
195195/**
196196 * Takes timestamp, treat it as time in provided timezone and returns the corresponding timestamp in UTC
197197 */
198- export const localTimestampToUtc = ( timezone : string , timestampFormat : string , timestamp : string ) : string | null => {
198+ export const localTimestampToUtc = ( timezone : string , timestampFormat : string , timestamp ? : string ) : string | null => {
199199 if ( ! timestamp ) {
200200 return null ;
201201 }
@@ -223,8 +223,14 @@ export const localTimestampToUtc = (timezone: string, timestampFormat: string, t
223223 } else if ( timestampFormat === 'YYYY-MM-DDTHH:mm:ss.SSS' ) {
224224 return inDbTimeZoneDate . toJSON ( ) . replace ( 'Z' , '' ) ;
225225 } else if ( timestampFormat === 'YYYY-MM-DDTHH:mm:ss.SSSSSS' ) {
226+ const value = inDbTimeZoneDate . toJSON ( ) ;
227+ if ( value . endsWith ( '999Z' ) ) {
228+ // emulate microseconds
229+ return value . replace ( 'Z' , '999' ) ;
230+ }
231+
226232 // emulate microseconds
227- return inDbTimeZoneDate . toJSON ( ) . replace ( 'Z' , '000' ) ;
233+ return value . replace ( 'Z' , '000' ) ;
228234 }
229235 }
230236
@@ -236,7 +242,7 @@ export const localTimestampToUtc = (timezone: string, timestampFormat: string, t
236242/**
237243 * Takes timestamp in UTC, shift it into provided timezone and returns the corresponding timestamp in UTC
238244 */
239- export const utcToLocalTimeZone = ( timezone : string , timestampFormat : string , timestamp : string ) : string | null => {
245+ export const utcToLocalTimeZone = ( timezone : string , timestampFormat : string , timestamp ? : string ) : string | null => {
240246 if ( ! timestamp ) {
241247 return null ;
242248 }
0 commit comments