parse a string containing date and time information
ParseTime( fmt, str )
string; format specifier
string; string to be parsed
The ParseTime( fmt,str ) command parses the string str, assumed to contain date and time data, according to the parsing specification given by the format string fmt.
The time format string is a Maple string that can contain time and date format conversion specifiers, introduced by a % character. This works in a manner similar to the conversion specifiers used in printf or sscanf, but the defined conversion specifiers are different. The format conversion specifiers are a subset of those supported by the FormatTime procedure.
The string str to be parsed is assumed to contain date and time information in the format described by fmt. Characters in fmt and str are matched, with the format conversion specifiers in fmt acting as placeholders or wildcards for the actual date and time data present in the string str. If the two strings match, then the date and time data extracted from str are returned in the form of a record, described below. If the strings fail to match, then an exception is raised.
The following table lists the known conversion specifiers and their meanings.
the string "%"
abbreviated weekday name
the full weekday name
abbreviated month name
full month name
a standard date and time representation
the century number (the year divided by 100 and truncated to an integer in the range 01 - 99)
a two-digit day of the month number
the date in the form MM/DD/YY.
the day of the month (01-31).
the hour in a 24-hour clock (00-23).
the hour in a 12-hour clock (01-12).
day number (01-366).
the hour in a 24-hour clock ( 0-23).
the hour in a 12-hour clock ( 1-12).
the month number (01-12).
the minute after the hour (00-59).
a newline character
a.m. or p.m.
time representation for a 12-hour clock (using %p).
the same as %H:%M.
seconds after the minute (00-61)
a tab character
same as %H:%M:%S.
weekday as a decimal number (1-7; 1 = Sunday).
week number of the year (00-53); Sunday is the first day of week 1.
The ISO 8601 week number (01-53).
weekday (0-6); 0 = Sunday.
a standard date representation.
a standard time representation.
year within the century (00-99)
year including the century (YYYY)
time zone name or abbreviation, if available.
The record returned by ParseTime contains slots with the following meanings and ranges of values.
seconds after the minute
minutes after the hour
hour of the day
day of the month
month of the year
day of the week
day of the year
if known, whether daylight savings time is in effect
Not all slots of this record will be updated for a given pair of inputs. Only those slots whose values can be determined from the given data will have meaningful values.
All of the StringTools package commands treat strings as (null-terminated) sequences of 8-bit (ASCII) characters. Thus, there is no support for multibyte character encodings, such as unicode encodings.
dt≔ParseTime⁡Welcome to the %Cth Century!,Welcome to the 19th Century!:
s≔Wed Mar 04 21:37:20 2020
Download Help Document
What kind of issue would you like to report? (Optional)