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.Get Time Separator (gts)

Previous Top Next


MiniRobotLanguage (MRL)

 

DTO.GetTimeSeparator Command

Detect the primary separator character in a time string or mask

 

Intention

 

This command examines either a time format mask or a time string itself to determine which character is used to separate the main time components (hours, minutes, seconds).

 

Priority:

1. It first looks for a valid separator in the FormatMask.

2. If no separator is found there (or the mask is not provided), it searches the TimeString.

3. If no separator is found in either, it returns the default separator: :.

 

Common time separators include :, ., -, space, etc. It distinguishes these from decimal separators (like . or ,) used for fractional seconds.

 

Syntax

 

DTO.gettimeseparator|[TimeString]|[FormatMask]|[$$RES]

DTO.gts|[TimeString]|[FormatMask]|[$$RES]

 

Parameter Explanation

 

P1 - TimeString (Optional)

The time string (or variable, e.g., $$TIM) to check for a separator if one isn't found in P2.

 

P2 - FormatMask (Optional)

The time format mask string (or variable, e.g., $$MSK) to check first for a separator.

 

P3 - $$RES (Optional)

The variable (e.g., $$RES) where the detected separator character will be stored. If omitted, the result is placed on TOS.

 

 

Example

 

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

' DTO.gts - Sample

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

'

' --- Example 1: Detect from Format Mask ---

$$MSK = "HH.MM.SS"

DTO.gts||$$MSK|$$SEP

DBV.Separator from mask: $$SEP ' Result: "."

'

' --- Example 2: Detect from Time String (Mask has no separator) ---

$$TIM = "14-30-45"

$$MSK = "HHMMSS" ' No separator in mask

DTO.gts|$$TIM|$$MSK|$$SEP

DBV.Separator from string: $$SEP ' Result: "-"

'

' --- Example 3: Default separator (no separator found) ---

$$TIM = "102030"

DTO.gts|$$TIM||$$SEP

DBV.Default Separator: $$SEP ' Result: ":"

'

' --- Example 4: Ignores decimal separator ---

$$TIM = "11:22:33.444"

DTO.gts|$$TIM||$$SEP

DBV.Separator ignoring decimal: $$SEP ' Result: ":"

'

ENR.

 

Remarks

 

This command is useful when you need to parse or format a time string but don't know the separator in advance.

It returns the *first* valid time separator it encounters according to the priority rules.

The function attempts to differentiate between the main time separator and separators used for fractional seconds (like '.' or ',' before milliseconds).

 

Limitations

 

- If a string contains mixed separators (e.g., "10:20.30"), it will return the first one found (':' in this case), which might not be consistently used throughout the string.

 

See also

 

    DTO. - Date Time Operations

    DTO.Get Date Separator - detect date separator char

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

    DTO.Parse Time - parse time into components

    DTO.Format Time - format time components to string

    DTO.Make Time Mask - create time format mask