This is the documentation for Clover Club 12.0.
Documentation for the upcoming version Rampur 13.0 can be found here.

Date, Time and Number Formatting

The following sections are cited from https://momentjs.com/docs/#/displaying/ for Date and Time formatting and http://www.gwtproject.org/ for Number formatting. 

Formatting Date and Time

Patterns



Token

Output



Token

Output

Month




M

1 2 ... 11 12

Mo

1st 2nd ... 11th 12th

MM

01 02 ... 11 12

MMM

Jan Feb ... Nov Dec

MMMM

January February ... November December

Quarter

Q

1 2 3 4

Qo

1st 2nd 3rd 4th

Day of Month


D

1 2 ... 30 31

Do

1st 2nd ... 30th 31st

DD

01 02 ... 30 31

Day of Year


DDD

1 2 ... 364 365

DDDo

1st 2nd ... 364th 365th

DDDD

001 002 ... 364 365

Day of Week




d

0 1 ... 5 6

do

0th 1st ... 5th 6th

dd

Su Mo ... Fr Sa

ddd

Sun Mon ... Fri Sat

dddd

Sunday Monday ... Friday Saturday

Day of Week (Locale)

e

0 1 ... 5 6

Day of Week (ISO)

E

1 2 ... 6 7

Week of Year


w

1 2 ... 52 53

wo

1st 2nd ... 52nd 53rd

ww

01 02 ... 52 53

Week of Year (ISO)


W

1 2 ... 52 53

Wo

1st 2nd ... 52nd 53rd

WW

01 02 ... 52 53

Year


YY

70 71 ... 29 30

YYYY

1970 1971 ... 2029 2030

Y

1970 1971 ... 9999 +10000 +10001
Note: This complies with the ISO 8601 standard for dates past the year 9999

Week Year

gg

70 71 ... 29 30

gggg

1970 1971 ... 2029 2030

Week Year (ISO)

GG

70 71 ... 29 30

GGGG

1970 1971 ... 2029 2030

AM/PM

A

AM PM

a

am pm

Hour





H

0 1 ... 22 23

HH

00 01 ... 22 23

h

1 2 ... 11 12

hh

01 02 ... 11 12

k

1 2 ... 23 24

kk

01 02 ... 23 24

Minute

m

0 1 ... 58 59

mm

00 01 ... 58 59

Second

s

0 1 ... 58 59

ss

00 01 ... 58 59

Fractional Second



S

0 1 ... 8 9

SS

00 01 ... 98 99

SSS

000 001 ... 998 999

SSSS ... SSSSSSSSS

000[0..] 001[0..] ... 998[0..] 999[0..]

Time Zone


z or zz

EST CST ... MST PST
Note: as of 1.6.0, the z/zz format tokens have been deprecated from plain moment objects. Read more about it here. However, they *do* work if you are using a specific time zone with the moment-timezone addon.

Z

-07:00 -06:00 ... +06:00 +07:00

ZZ

-0700 -0600 ... +0600 +0700

Unix Timestamp

X

1360013296

Unix Millisecond Timestamp

x

1360013296123

Localized Formats

Because preferred formatting differs based on locale, there are a few tokens that can be used to format a moment based on its locale.

There are upper and lower case variations on the same formats. The lowercase version is intended to be the shortened version of its uppercase counterpart.

Time

LT

8:30 PM

Time

LT

8:30 PM

Time with seconds

LTS

8:30:25 PM

Month numeral, day of month, year

L

09/04/1986

l

9/4/1986

Month name, day of month, year

LL

September 4, 1986

ll

Sep 4, 1986

Month name, day of month, year, time

LLL

September 4, 1986 8:30 PM

lll

Sep 4, 1986 8:30 PM

Month name, day of month, day of week, year, time

LLLL

Thursday, September 4, 1986 8:30 PM

llll

Thu, Sep 4, 1986 8:30 PM

Escaping Characters

To escape characters in format strings, you can wrap the characters in square brackets.

moment().format('[today] dddd'); // 'today Sunday'

moment().format('[today] dddd'); // 'today Sunday'

Formatting Numbers

Patterns

Formatting is based on customizable patterns that can include a combination of literal characters and special characters that act as placeholders and are replaced by their localized counterparts. Many characters in a pattern are taken literally; they are unchanged during formatting. Special characters, on the other hand, stand for other characters, strings, or classes of characters. For example, the '#' character is replaced by a localized digit.

Often the replacement character is the same as the pattern character. In the U.S. locale, for example, the ',' grouping character is replaced by the same character ','. However, the replacement is still actually happening, and in a different locale, the grouping character may change to a different character, such as '.'. Some special characters affect the behavior of the formatter by their presence. For example, if the percent character is seen, then the value is multiplied by 100 before being displayed.

The characters listed below are used in patterns. Localized symbols use the corresponding characters taken from corresponding locale symbol collection. To insert a special character in a pattern as a literal (that is, without any special meaning) the character must be quoted. There are some exceptions to this which are noted below.

Symbol 

Location

Localized?

Meaning

Symbol 

Location

Localized?

Meaning

0

Number

Yes

Digit

There is support for K, M, B abbreviations in custom formatting: 0.0K / 0.0M / 0.0B where "0" drives the number of digits (# can be used too). 

Example for number "44,774.13":

  • Formatted as "0K" returns "45K"

  • Formatted as "0.0K" returns "44.8K"

  • Formatted as "0.00K" returns "44.77K"

 # 

Number

Yes

Digit, zero shows as absent

Examples of use: 

  • # represents one digit but it is optional, ​so if you format 10.0001 as #'###.## you will end up with 10

  • If you want to force that a certain digit shows up, you use 0 instead of #

    • ​10.001 formatted with 0'000.00 would be displayed as 0'010.00 (just an example)

    • A ​more typical pattern would be #'###.00 -> 10.00
      or

    • #'###.000 -> 10.001

  • If you format 1 with #'###.00 you will end up with 1.00

  • Also, most characters are not interpreted, so if the format string is "Value: #.## USD" and the number is 1.2, the formatting displays "Value: 1.2 USD"

. 

Number

Yes

Decimal separator or monetary decimal separator

- 

Number

Yes

Minus sign

, 

Number

Yes

Grouping separator

E 

Number

Yes

Separates mantissa and exponent in scientific notation; need not be quoted in prefix or suffix

; 

Subpattern boundary

Yes

Separates positive and negative subpatterns  (see details below the table)

% 

Prefix or Suffix 

Yes

Multiply by 100 and show as percentage

? (\u2030) 

Prefix or Suffix 

Yes

Multiply by 1000 and show as per million

¤ (\u00A4) 

Prefix or Suffix 

No

Currency sign, replaced by currency symbol; if doubled, replaced by international currency symbol; if present in a pattern, the monetary decimal separator is used instead of the decimal separator

' 

Prefix or Suffix 

No

Used to quote special characters in a prefix or suffix; for example, "'#'#" formats 123 to "#123"; to create a single quote itself, use two in succession, such as "# o''clock"

If there is a semicolon in the pattern, then the first part (subpattern) is for positive values and the second is for negative ones, e.g. "#,##0.00;(#,##0.00)". Each subpattern has a prefix, a numeric part, and a suffix. If there is no explicit negative subpattern, the negative subpattern is the localized minus sign prefixed to the positive subpattern. That is, "0.00" alone is equivalent to "0.00;-0.00". If there is an explicit negative subpattern, it serves only to specify the negative prefix and suffix; the number of digits, minimal digits, and other characteristics are ignored in the negative subpattern. That means that "#,##0.0#;(#)" has precisely the same result as "#,##0.0#;(#,##0.0#)".

The prefixes, suffixes, and various symbols used for infinity, digits, thousands separators, decimal separators, etc. may be set to arbitrary values, and they will appear properly during formatting. However, care must be taken that the symbols and strings do not conflict, or parsing will be unreliable. For example, the decimal separator and thousands separator should be distinct characters, or parsing will be impossible.

The grouping separator is a character that separates clusters of integer digits to make large numbers more legible. It commonly used for thousands, but in some locales it separates ten-thousands. The grouping size is the number of digits between the grouping separators, such as 3 for "100,000,000" or 4 for "1 0000 0000".

Pattern Grammar (BNF)

The pattern itself uses the following grammar:

pattern

:=

subpattern (';' subpattern)?

subpattern

:=

prefix? number exponent? suffix?

number

:=

(integer ('.' fraction)?) | sigDigits

prefix

:=

'\u0000'..'\uFFFD' - specialCharacters

suffix

:=

'\u0000'..'\uFFFD' - specialCharacters

integer

:=

'#'* '0'*'0'

fraction

:=

'0'* '#'*

sigDigits

:=

'#'* '@''@'* '#'*

exponent

:=

'E' '+'? '0'* '0'

padSpec

:=

'*' padChar

padChar

:=

'\u0000'..'\uFFFD' - quote



Notation:

X* 

0 or more X symbols

X? 

0 or 1 X symbols

X|Y 

either X or Y

C..F

any symbol from C to F included

S-T 

symbols in S, excluding those in T

The first subpattern is for positive numbers. The second (optional) subpattern is for negative numbers.