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 Wednesday

(1)

sVariantFormatToday

s2023-03-08T11:47:25

(2)

VariantParses

Date2023,3,8,11,47,25,timezone=UTC,coefficient=1

(3)

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

seqprintf%%%c - %s ,ch,StringTools:-VisibleVariantFormatToday,cat%,ch,ch=%aAbBcDgGHIjmMnprRStTuUVwxXyYzZ

%%        -        %
%a        -        Wed
%A        -        Wednesday
%b        -        Mar
%B        -        March
%c        -        Wed Mar 08 11:47:26 2023
%D        -        03/08/23
%g        -        23
%G        -        2023
%H        -        11
%I        -        11
%j        -        067
%m        -        03
%M        -        47
%n        -        \10
%p        -        AM
%r        -        11:47:26 AM
%R        -        11:47
%S        -        26
%t        -        \9
%T        -        11:47:26
%u        -        4
%U        -        10
%V        -        10
%w        -        4
%x        -        03/08/23
%X        -        11:47:26
%y        -        23
%Y        -        2023
%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,%c,'locale'=ja

水 3月 08 11:47:26 2023

(4)

sVariantFormatToday,%c,'locale'=de

sMi. März 08 11:47:26 2023

(5)

VariantParses,%c,'locale'=de

Date2023,3,8,11,47,26,timezone=UTC,coefficient=1

(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]