Skip to content

Instantly share code, notes, and snippets.

@fsans
Last active October 6, 2022 16:30
Show Gist options
  • Save fsans/d15d36fc8b56eb8feade2cd5e0f1d5cf to your computer and use it in GitHub Desktop.
Save fsans/d15d36fc8b56eb8feade2cd5e0f1d5cf to your computer and use it in GitHub Desktop.
Convert between ISO8601 and FileMaker Time formats

ISO8601GetTime(isoDate)

Let ( 
  [
	_input_date = Filter( GetValue( Split( isoDate; "T" ); 1 ); "0123456789");
	_input_time = Filter( GetValue ( Split ( GetValue( Split( GetValue( Split( isoDate; "T" ); 2 ) ; "+" ); 1) ; "-" ) ; 1 ); "0123456789.");
	_hour = Left(_input_time;2);
	_minute = Middle ( _input_time ; 3 ; 2 );
	_seccond = Middle ( _input_time ; 5 ; 99 )
  ] ;
  Time ( _hour; _minute; _seccond )
)

ISO8601FormatTime(fmTimestamp)

Case ( 
  not IsEmpty ( fmTime ) ; 
  Right ( "0" & Hour( fmTime ) ; 2 ) & ":" & Right ( "0" & Minute ( fmTime ) ; 2 ) & ":" & Right ( "0" & Seconds ( fmTime ) ; 2 ) 
)

ISO8601FormatTimestamp()

Case ( 
  not IsEmpty ( fmTimestamp ) ; 
  ISO8601FormatDate( fmTimestamp )  & "T" & ISO8601FormatTime ( fmTimestamp ) 
)

ISO8601ParseTime(isoDate)

Let ( 
  [
	_input_date = Filter( GetValue( Split( isoDate; "T" ); 1 ); "0123456789");
	_input_time = Filter( GetValue ( Split ( GetValue( Split( GetValue( Split( isoDate; "T" ); 2 ) ; "+" ); 1) ; "-" ) ; 1 ); "0123456789.");
	_hour = Left(_input_time;2);
	_minute = Middle ( _input_time ; 3 ; 2 );
	_seccond = Middle ( _input_time ; 5 ; 99 )
  ] ;
  Time ( _hour; _minute; _seccond )
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment