VariantFormat - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


Calendar

  

VariantFormat

  

format a Date or UTC Time object as a string

  

VariantParse

  

parse a string to a Date object with respect to a given format string

 

Calling Sequence

Parameters

Options

Description

Format Conversion Specifiers

Examples

References

Compatibility

Calling Sequence

VariantFormat( d, fmt )

VariantParse( s, fmt )

Parameters

d

-

Date; a Date object

s

-

string; string to parse

fmt

-

string; (optional) a format string

Options

• 

locale : string; the name of a locale to use

Description

• 

Dates (and Time objects) can be formatted to a string by using the VariantFormat( d, fmt ) command.

• 

A string containing date information can be parsed to produce a corresponding Date object by using the VariantParse( s, fmt ) command.

• 

The format string fmt is a string of free-form text with format conversion specifiers similar to those used by printf.

• 

The format string fmt is optional.  Its default value is the string "%Y-%m-%dT%T".

• 

A richer set of formatting and parsing specifiers are provided by Calendar[Format] and Calendar[Parse]. The VariantFormat and VariantParse commands are intended to be similar to the facilities provided by StringTools[FormatTime] and StringTools[ParseTime] commands.

• 

Use the locale = loc option to control which locale formatting and parsing occurs in. The loc value should be a two-letter language code (E.g., "id" for Indonesian), optionally separated by an underscore character ("_") from a country variant indicates by using a two- or three-letter country code. (E.g., "fr_CA" for Canadian French.)

• 

For some of the examples below to print correctly, you may need special fonts to be installed on your computer.

Format Conversion Specifiers

• 

The following table details the supported format conversion specifiers.

%%

the string "%".

%a

abbreviated weekday name.

%A

the full weekday name.

%b

abbreviated month name.

%h

abbreviated month name.

%B

full month name.

%c

a standard date and time representation, equivalent to "%a %b %d %H:%M:%S %Y".

%d

the two-digit day of the month number (01-31).

%D

the date in the form equivalent to "%m/%d/%y".

%g

two digit ISO year of week

%G

four digit ISO year of week

%H

the hour of the day in a 24-hour clock (00-23).

%I

the hour of the day in a 12-hour clock (01-12).

%j

the day of the year (001 - 366).

%m

the two-digit month number (01 - 12).

%M

the two-digit minute after the hour (00-59).

%n

a newline character.

%p

a.m. or p.m. for a 12-hour clock

%r

time representation for a 12-hour clock equivalent to "%I:%M:%S %p".

%R

an abbreviated time of the day, equivalent to "%H:%M".

%S

seconds after the minute (00 - 61).

%t

a tab character.

%T

the time of the day, equivalent to "%H:%M:%S".

%u

weekday as a decimal number (1-7; 1 = Monday).

%U

week number of the year (00 - 53); Sunday is the first day of week 1.

%V

The ISO 8601 week number (01 - 53).

%w

weekday (0-6); 0 = Sunday.

%x

a representation of the date equivalent to "%m/%d/%y"

%X

a time of day representation equivalent to "%H:%M:%S"

%y

the two-digit year within the century (00 - 99).

%Y

the four-digit year including the century (YYYY).

%z

timezone offset east of GMT

%Z

time zone name or abbreviation

Examples

withCalendar:

VariantFormatToday,The day of the week is %A

The day of the week is Friday

(1)

sVariantFormatToday

s2024-03-01T05:28:49

(2)

VariantParses

<Date: 2024-03-01T05:28:49 GMT>

(3)

Here are the effects for each format conversion specifier on the current date.

seqprintf%%%c\t-\t%s\n&comma;ch&comma;StringTools:-VisibleVariantFormatToday&comma;cat%&comma;ch&comma;ch=%aAbBcDgGHIjmMnprRStTuUVwxXyYzZ

%%    -    %
%a    -    Fri
%A    -    Friday
%b    -    Mar
%B    -    March
%c    -    Fri Mar 01 05:28:49 2024
%D    -    03/01/24
%g    -    24
%G    -    2024
%H    -    05
%I    -    05
%j    -    061
%m    -    03
%M    -    28
%n    -    \10
%p    -    AM
%r    -    05:28:49 AM
%R    -    05:28
%S    -    49
%t    -    \9
%T    -    05:28:49
%u    -    6
%U    -    09
%V    -    09
%w    -    6
%x    -    03/01/24
%X    -    05:28:49
%y    -    24
%Y    -    2024
%z    -    +0000
%Z    -    Etc/UTC

(Note that these values reflect those in effect at the time this help page was generated.)

To use a locale different from the default locale, use the locale= option.

VariantFormatToday&comma;%c&comma;locale=ja

金 3月 01 05:28:49 2024

(4)

sVariantFormatToday&comma;%c&comma;locale=de

sFr. März 01 05:28:49 2024

(5)

VariantParses&comma;%c&comma;locale=de

<Date: 2024-03-01T05:28:49 GMT>

(6)

References

  

ISO 639.2

Compatibility

• 

The Calendar[VariantFormat] and Calendar[VariantParse] commands were introduced in Maple 2019.

• 

For more information on Maple 2019 changes, see Updates in Maple 2019.

See Also

Calendar

Calendar[Format]

Calendar[Parse]

Date

StringTools[FormatTime]

StringTools[ParseTime]

StringTools[Visible]