|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Date and Time Calculation > DTO. - Date Time Operations > Date & Time Operations |
MiniRobotLanguage (MRL)
DTO.splittime Command
Extract Hour, Minute, and Second from a time string
Intention
This command parses a given time string based on a format mask and stores the individual components (Hour, Minute, Second) into separate variables. This is the counterpart to DTO.FormatTime.
The format mask components are:
• HH (2-digit hour), H (1-2 digit hour)
• MM (2-digit minute), M (1-2 digit minute)
• SS (2-digit second), S (1-2 digit second)
• .XXXX (fractional part - not fully supported by this old command, use DTO.ParseTime)
Syntax
DTO.splittime|TimeString|$$HOU|$$MIN|$$SEC[|FormatMask]
DTO.splittimemask|...
DTO.sptm|...
Parameter Explanation
P1 - TimeString (Required)
The time string (or a variable) that you want to parse.
Example: "14:30:45"
P2 - $$HOU (Optional)
A variable (max 5 chars, e.g., $$HOU) to store the extracted Hour component.
P3 - $$MIN (Optional)
A variable (max 5 chars, e.g., $$MIN) to store the extracted Minute component.
P4 - $$SEC (Optional)
A variable (max 5 chars, e.g., $$SEC) to store the extracted Second component.
P5 - FormatMask (Optional but recommended)
The string mask describing the format of P1. Example: "HH:MM:SS"
Example
'**********************************************
' DTO.splittime - Sample
'**********************************************
'
' --- Example 1: Split standard time ---
$$TIM = "14:30:45"
$$MSK = "HH:MM:SS"
DTO.splittime|$$TIM|$$HOU|$$MIN|$$SEC|$$MSK
DBV.Hour: $$HOU ' Result: 14
DBV.Minute: $$MIN ' Result: 30
DBV.Second: $$SEC ' Result: 45
'
' --- Example 2: Different separator and order ---
$$TIM = "59.10.23" ' 59 sec, 10 min, 23 hr
$$MSK = "SS.MM.HH"
DTO.splittime|$$TIM|$$H|$$M|$$S|$$MSK
DBV.Hour: $$H ' Result: 23
DBV.Minute: $$M ' Result: 10
DBV.Second: $$S ' Result: 59
'
' --- Example 3: Only get Minutes ---
$$TIM = "08:15:10"
DTO.splittime|$$TIM||$$MIN||"HH:MM:SS"
DBV.Minute: $$MIN ' Result: 15
'
ENR.
Remarks
-
Limitations
- The FormatMask parameter (P5) is required for the command to work.
- This command does not parse fractional seconds (milliseconds). Use DTO.ParseTime for that.
- If the time string is invalid (e.g., "25:70:99"), the variables will not be set correctly (will contain 0).
See also
• DTO.Parse Time - (Recommended replacement)
• DTO.Format Time - format time components to string
• DTO.Split Date Mask - extract day/month/year from date
• DTO.Make Time Mask - create time format mask