@@ -53,7 +53,11 @@ INTERFACE
5353 END_STRUCT
5454
5555 TIME_OF_DAY_FORMAT : (
56- ISO8601 // time of day in ISO 8601 representation (e.g. ' 21:34:56.789' )
56+ ISO8601 , // time of day in ISO 8601 representation (e.g. ' 21:34:56.789' )
57+ ISO8601_HHMM , // time of day in ISO 8601 representation without seconds and milliseconds (e.g. ' 21:34' )
58+ ISO8601_HHMM_NODLM , // time of day in ISO 8601 representation without seconds, milliseconds and delimiters (e.g. ' 2134' )
59+ ISO8601_HHMMSS , // time of day in ISO 8601 representation without milliseconds (e.g. ' 213456' )
60+ ISO8601_HHMMSS_NODLM // time of day in ISO 8601 representation without milliseconds and delimiters (e.g. ' 21:34:56' )
5761 );
5862
5963 // Contains all parts of a local date (year, month, day, etc.).
@@ -64,7 +68,9 @@ INTERFACE
6468 END_STRUCT
6569
6670 DATE_FORMAT : (
67- ISO8601 // date in ISO 8601 representation (e.g. ' 2019-10-31' )
71+ ISO8601 , // date in ISO 8601 representation (e.g. ' 2019-10-31' )
72+ ISO8601_NODLM , // date in ISO 8601 representation without delimiters (e.g. ' 20191031' )
73+ DIN5008 // date in common DIN 5008 :2011 representation (e.g. ' 31.10.2019' )
6874 );
6975
7076 DAY_OF_WEEK_TYPE : (
@@ -502,10 +508,10 @@ IMPLEMENTATION
502508
503509 hours := (minutes - out.minute) / 60 ;
504510 out.hour := UDINT_TO_USINT (hours MOD 24 );
505-
511+
506512 days := (hours - out.hour) / 24 ;
507513 out.day := UDINT_TO_USINT (days);
508-
514+
509515 DISSECT_TIME := out;
510516 END_FUNCTION
511517
@@ -535,7 +541,7 @@ IMPLEMENTATION
535541
536542 hours := (minutes - out.minute) / 60 ;
537543 out.hour := UDINT_TO_USINT (hours MOD 24 );
538-
544+
539545 DISSECT_TIME_OF_DAY := out;
540546 END_FUNCTION
541547
@@ -730,27 +736,27 @@ IMPLEMENTATION
730736 in : TIME_DISSECTED ;
731737 format : TIME_FORMAT ; // currently, only ISO 8601 is supported
732738 END_VAR
733-
739+
734740 VAR_TEMP
735741 out : STRING [18 ];
736742 END_VAR
737-
743+
738744 out := ' P' ;
739-
745+
740746 IF in.day <> 0 THEN
741747 out := CONCAT3 (out, USINT_TO_STRING (in.day), ' D' );
742748 END_IF ;
743-
749+
744750 out := CONCAT (out, ' T' );
745-
751+
746752 IF in.hour <> 0 THEN
747753 out := CONCAT3 (out, USINT_TO_STRING (in.hour), ' H' );
748754 END_IF ;
749-
755+
750756 IF in.minute <> 0 THEN
751757 out := CONCAT3 (out, USINT_TO_STRING (in.minute), ' M' );
752758 END_IF ;
753-
759+
754760 IF in.second <> 0 OR in.millisecond <> 0 THEN
755761 out := CONCAT5 (out, USINT_TO_STRING (in.second), ' .' , PAD_STRING_LEFT (UINT_TO_STRING (in.millisecond), 3 , ' 0' ), ' S' );
756762 END_IF ;
@@ -773,18 +779,41 @@ IMPLEMENTATION
773779 FUNCTION FORMAT_TIME_OF_DAY_DISSECTED : STRING [12 ]
774780 VAR_INPUT
775781 in : TIME_OF_DAY_DISSECTED ;
776- format : TIME_OF_DAY_FORMAT ; // currently, only ISO 8601 is supported
782+ format : TIME_OF_DAY_FORMAT ;
777783 END_VAR
778784
779- FORMAT_TIME_OF_DAY_DISSECTED := CONCAT7 (
780- PAD_STRING_LEFT (USINT_TO_STRING (in.hour), 2 , ' 0' ),
781- ' :' ,
782- PAD_STRING_LEFT (USINT_TO_STRING (in.minute), 2 , ' 0' ),
783- ' :' ,
784- PAD_STRING_LEFT (USINT_TO_STRING (in.second), 2 , ' 0' ),
785- ' .' ,
786- PAD_STRING_LEFT (UINT_TO_STRING (in.millisecond), 3 , ' 0' )
787- );
785+ CASE format OF
786+ ISO8601: FORMAT_TIME_OF_DAY_DISSECTED := CONCAT7 (
787+ PAD_STRING_LEFT (USINT_TO_STRING (in.hour), 2 , ' 0' ),
788+ ' :' ,
789+ PAD_STRING_LEFT (USINT_TO_STRING (in.minute), 2 , ' 0' ),
790+ ' :' ,
791+ PAD_STRING_LEFT (USINT_TO_STRING (in.second), 2 , ' 0' ),
792+ ' .' ,
793+ PAD_STRING_LEFT (UINT_TO_STRING (in.millisecond), 3 , ' 0' )
794+ );
795+ ISO8601_HHMMSS: FORMAT_TIME_OF_DAY_DISSECTED := CONCAT5 (
796+ PAD_STRING_LEFT (USINT_TO_STRING (in.hour), 2 , ' 0' ),
797+ ' :' ,
798+ PAD_STRING_LEFT (USINT_TO_STRING (in.minute), 2 , ' 0' ),
799+ ' :' ,
800+ PAD_STRING_LEFT (USINT_TO_STRING (in.second), 2 , ' 0' )
801+ );
802+ ISO8601_HHMMSS_NODLM: FORMAT_TIME_OF_DAY_DISSECTED := CONCAT3 (
803+ PAD_STRING_LEFT (USINT_TO_STRING (in.hour), 2 , ' 0' ),
804+ PAD_STRING_LEFT (USINT_TO_STRING (in.minute), 2 , ' 0' ),
805+ PAD_STRING_LEFT (USINT_TO_STRING (in.second), 2 , ' 0' )
806+ );
807+ ISO8601_HHMM: FORMAT_TIME_OF_DAY_DISSECTED := CONCAT3 (
808+ PAD_STRING_LEFT (USINT_TO_STRING (in.hour), 2 , ' 0' ),
809+ ' :' ,
810+ PAD_STRING_LEFT (USINT_TO_STRING (in.minute), 2 , ' 0' )
811+ );
812+ ISO8601_HHMM_NODLM: FORMAT_TIME_OF_DAY_DISSECTED := CONCAT (
813+ PAD_STRING_LEFT (USINT_TO_STRING (in.hour), 2 , ' 0' ),
814+ PAD_STRING_LEFT (USINT_TO_STRING (in.minute), 2 , ' 0' )
815+ );
816+ END_CASE ;
788817 END_FUNCTION
789818
790819 // Formats given time using specified format and returns created string.
@@ -802,16 +831,30 @@ IMPLEMENTATION
802831 FUNCTION FORMAT_DATE_DISSECTED : STRING [10 ]
803832 VAR_INPUT
804833 in : DATE_DISSECTED ;
805- format : DATE_FORMAT ; // currently, only ISO 8601 is supported
834+ format : DATE_FORMAT ;
806835 END_VAR
807-
808- FORMAT_DATE_DISSECTED := CONCAT5 (
809- UINT_TO_STRING (in.year),
810- ' -' ,
811- PAD_STRING_LEFT (USINT_TO_STRING (in.month), 2 , ' 0' ),
812- ' -' ,
813- PAD_STRING_LEFT (USINT_TO_STRING (in.day), 2 , ' 0' )
814- );
836+
837+ CASE format OF
838+ ISO8601: FORMAT_DATE_DISSECTED := CONCAT5 (
839+ UINT_TO_STRING (in.year),
840+ ' -' ,
841+ PAD_STRING_LEFT (USINT_TO_STRING (in.month), 2 , ' 0' ),
842+ ' -' ,
843+ PAD_STRING_LEFT (USINT_TO_STRING (in.day), 2 , ' 0' )
844+ );
845+ ISO8601_NODLM: FORMAT_DATE_DISSECTED := CONCAT3 (
846+ UINT_TO_STRING (in.year),
847+ PAD_STRING_LEFT (USINT_TO_STRING (in.month), 2 , ' 0' ),
848+ PAD_STRING_LEFT (USINT_TO_STRING (in.day), 2 , ' 0' )
849+ );
850+ DIN5008: FORMAT_DATE_DISSECTED := CONCAT5 (
851+ PAD_STRING_LEFT (USINT_TO_STRING (in.day), 2 , ' 0' ),
852+ ' .' ,
853+ PAD_STRING_LEFT (USINT_TO_STRING (in.month), 2 , ' 0' ),
854+ ' .' ,
855+ UINT_TO_STRING (in.year)
856+ );
857+ END_CASE ;
815858 END_FUNCTION
816859
817860 // Formats given date using specified format and returns created string.
@@ -820,7 +863,7 @@ IMPLEMENTATION
820863 in : DATE ;
821864 format : DATE_FORMAT ;
822865 END_VAR
823-
866+
824867 FORMAT_DATE := FORMAT_DATE_DISSECTED (DISSECT_DATE (in), format);
825868 END_FUNCTION
826869
@@ -831,7 +874,7 @@ IMPLEMENTATION
831874 in : DATE_AND_TIME_DISSECTED ;
832875 format : DATE_AND_TIME_FORMAT ; // currently, only ISO 8601 is supported
833876 END_VAR
834-
877+
835878 FORMAT_DATE_AND_TIME_DISSECTED := CONCAT3 (
836879 CONCAT5 (
837880 UINT_TO_STRING (in.year),
0 commit comments