File tree Expand file tree Collapse file tree
packages/destination-actions/src/destinations/customerio Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- import { resolveIdentifiers , isIsoDate } from '../utils'
1+ import { convertValidTimestamp , resolveIdentifiers , isIsoDate } from '../utils'
22
33describe ( 'isIsoDate' , ( ) => {
44 it ( 'should return true for valid ISO date with fractional seconds from 1-9 digits' , ( ) => {
@@ -79,3 +79,9 @@ describe('resolveIdentifiers', () => {
7979 expect ( resolveIdentifiers ( { } ) ) . toBeUndefined ( )
8080 } )
8181} )
82+
83+ describe ( 'convertValidTimestamp' , ( ) => {
84+ it ( 'should leave decimal unix timestamps unchanged' , ( ) => {
85+ expect ( convertValidTimestamp ( '1712345678.123' ) ) . toBe ( '1712345678.123' )
86+ } )
87+ } )
Original file line number Diff line number Diff line change @@ -39,10 +39,11 @@ export enum AccountRegion {
3939
4040export const convertValidTimestamp = < Value = unknown > ( value : Value ) : Value | number => {
4141 // Timestamps may be on a `string` field, so check if the string is only
42- // numbers. If it is, ignore it since it's probably already a unix timestamp.
42+ // digits (optionally with a fractional part). If it is, ignore it since
43+ // it's probably already a unix timestamp (integer or decimal).
4344 // DayJS doesn't parse unix timestamps correctly outside of the `.unix()`
4445 // initializer.
45- if ( typeof value !== 'string' || / ^ \d + $ / . test ( value ) ) {
46+ if ( typeof value !== 'string' || / ^ \d + ( \. \d + ) ? $ / . test ( value ) ) {
4647 return value
4748 }
4849
You can’t perform that action at this time.
0 commit comments