Date & Time Operations

<< Click to Display Table of Contents >>

Navigation:  3. Script Language > Date and Time Calculation > DTO. - Date Time Operations >

Date & Time Operations

DTO.Count Time Separators (cts)

Previous Top Next


MiniRobotLanguage (MRL)

 

DTO.CountTimeSeparators Command

Count time separator characters in a string

 

Intention

 

This command counts the total number of occurrences of known time separator characters within a given text string. It helps determine the structure of a potential time string.

 

The characters recognized as time separators are defined by the internal DTO.IsTimeSeparator check, which includes common characters like ':', '.', '-', as well as spaces and some typographical symbols.

 

Syntax

 

DTO.cts|TextString[|$$RES]

DTO.CountTimeSeparators|TextString[|$$RES]

 

Parameter Explanation

 

P1 - TextString (Required)

The string (or a variable, e.g., $$TXT) in which to count time separators.

Example: "14:30:15.500"

 

P2 - $$RES (Optional)

The variable (e.g., $$RES) where the resulting count (a number) will be stored. If omitted, the count is placed on TOS.

 

 

Example

 

'**********************************************

' DTO.cts - Sample

'**********************************************

'

' --- Example 1: Standard time string ---

$$TXT1 = "14:30:45"

DTO.cts|$$TXT1|$$CNT1

DBV.Count 1: $$CNT1 ' Result: 2

'

' --- Example 2: Time with milliseconds ---

$$TXT2 = "09.05.10.123"

DTO.cts|$$TXT2|$$CNT2

DBV.Count 2: $$CNT2 ' Result: 3

'

' --- Example 3: String with mixed separators ---

$$TXT3 = "23-59 58"

DTO.cts|$$TXT3|$$CNT3

DBV.Count 3: $$CNT3 ' Result: 2 (counts '-' and ' ')

'

' --- Example 4: String with no separators (to TOS) ---

DTO.cts|"Hello World"

POP.$$TOS

DBV.Count 4: $$TOS ' Result: 1 (counts the space)

'

ENR.

 

Remarks

 

This command is useful for quickly checking if a string potentially contains multiple time components (e.g., hours, minutes, seconds, milliseconds).

A count of 0 usually indicates only hours or an invalid string.

A count of 1 usually indicates hours and minutes.

A count of 2 usually indicates hours, minutes, and seconds.

A count of 3 or more might indicate the presence of fractional seconds.

 

Limitations

 

- The command only counts recognized separators; it does not validate the overall time format or the numeric components.

- It counts all occurrences, even if they appear consecutively or in incorrect positions (e.g., "::12::30" would count 4 separators).

 

See also

 

    DTO. - Date Time Operations

    DTO.Is Time Separator - check if char is time separator

    DTO.Get Time Separator - detect time separator char

    DTO.Get Time Milliseconds - get milliseconds separator

    DTO.Parse Time - parse time into components