|
<< Click to Display Table of Contents >> Navigation: 3. Script Language > Date and Time Calculation > DTO. - Date Time Operations > Date & Time Calculations |
MiniRobotLanguage (MRL)
DTO.AddMinutes Command
Add or Subtract Minutes from a Time Value
Intention
The DTO.AddMinutes command performs time arithmetic by adding a specified number of minutes to a given time. It intelligently handles rollovers, so if the calculation crosses the hour or midnight, the time adjusts correctly.
This command is perfect for calculating end times, scheduling events, or adjusting timestamps. You can also subtract minutes by providing a negative number, making it easy to find a time in the past.
Syntax
DTO.AddMinutes|time|minutes|[format]|[$$RES]
Parameter Explanation
time - The base time string (e.g., "14:30:00") to which minutes will be added. This can be a variable or a literal.
minutes - The number of minutes to add. Use a positive value to move forward in time and a negative value to move backward.
format - (Optional) A format mask that defines the layout of both the input `time` and the resulting output time. If omitted, "HH:MM:SS" is used by default.
$$RES - (Optional) The variable to store the new, calculated time string.
Example
'**********************************************
' DTO.AddMinutes - Sample
'**********************************************
'
' --- Sample 1: Add 90 minutes to a time, crossing the hour boundary ---
$$TIA = "13:15:00"
DTO.AddMinutes|$$TIA|90||$$TIB
MBX.Original: $$TIA, After adding 90 mins: $$TIB ' Result: 14:45:00
'
' --- Sample 2: Subtract 45 minutes from a time ---
$$TIC = "08:30:00"
DTO.AddMinutes|$$TIC|-45||$$TID
MBX.Original: $$TIC, After subtracting 45 mins: $$TID ' Result: 07:45:00
'
' --- Sample 3: Add minutes that cross midnight, using a custom format ---
$$TIE = "23-40"
$$FMT = "HH-MM"
DTO.AddMinutes|$$TIE|30|$$FMT|$$TIF
MBX.Start: $$TIE, After 30 mins: $$TIF ' Result: 00-10
ENR.
Remarks
The command operates on a 24-hour cycle. Adding minutes that exceed 24 hours (1440 minutes) will wrap around. For calculations spanning multiple days, it is better to work with full date-time objects.
Limitations:
The input `time` string must be valid and match the specified `format` (or the default format) to avoid errors.
See also:
• DTC. - Date and Time Calculation