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 Milliseconds (gtms)

Previous Top Next


MiniRobotLanguage (MRL)

 

DTO.gms Command

Get the numeric millisecond value from a time string

 

Intention

 

This command parses a time string, based on an optional format mask, and extracts the numeric value of the milliseconds (or fractional seconds) part.

The command understands fractional parts specified in the format mask (e.g., '.ttt', ',XXXX'). It returns the value scaled to milliseconds (0-999).

 

Syntax

 

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

DTO.get milliseconds|...

 

Parameter Explanation

 

P1 - TimeString (Required)

The time string (or a variable, e.g., $$TIM) containing the time value.

Example: "14:30:45.123"

 

P2 - FormatMask (Optional)

The format mask string (or variable) describing the structure of P1.

Example: "HH:MM:SS.ttt". If omitted, a default mask including milliseconds (like "HH:MM:SS.ttt" with ':' separator) is assumed.

 

P3 - $$RES (Optional)

The variable (e.g., $$RES) where the numeric millisecond value (0-999) will be stored. If omitted, the result is placed on TOS.

 

 

Example

 

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

' DTO.gtms - Sample

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

'

' --- Example 1: Get milliseconds (default mask) ---

$$TIM = "14:30:45.123"

DTO.gtms|$$TIM||$$MS1

DBV.Milliseconds 1: $$MS1 ' Result: 123

'

' --- Example 2: Get milliseconds with specific mask (comma sep, XXXX) ---

$$TIM = "10:20:30,4567"

$$MSK = "HH:MM:SS,XXXX"

DTO.gtms|$$TIM|$$MSK|$$MS2

DBV.Milliseconds 2: $$MS2 ' Result: 456 (4567 / 10 = 456)

'

' --- Example 3: No fractional part ---

$$TIM = "08:00:00"

DTO.gtms|$$TIM||$$MS3

DBV.Milliseconds 3: $$MS3 ' Result: 0

'

ENR.

 

Remarks

 

This command now correctly returns the **numeric millisecond value** (0-999).

The underlying parsing function (`INT_ParseTimeComponents`) reads the fractional part as 0-9999 (1/10000ths). This command scales that value down to milliseconds by dividing by 10.

To get the separator character used before the milliseconds, use the new command DTO.getmsseparator (gmssep).

 

Limitations

 

- If the time string cannot be parsed correctly using the mask, the result will be 0.

 

See also

 

    DTO. - Date Time Operations

    DTO.Get Milliseconds Separator (gmssep)

    DTO.Parse Time - parse time into components

    DTO.Get Hour (ghou)

    DTO.Get Minute (gmin)

    DTO.Get Second (gsec)