0.3.2 • Published 5 years ago
pandaman v0.3.2
pandaman
一个简单易上手的工具库
install
$ npm install --save pandaman
API
date
这是一个柯里化的方法,用例如下 Standard Date and Time Format Specifiers
Format | Description | Example |
---|---|---|
s | The seconds of the minute between 0-59. | "0" to "59" |
ss | The seconds of the minute with leading zero if required. | "00" to "59" |
m | The minute of the hour between 0-59. | "0" or "59" |
mm | The minute of the hour with leading zero if required. | "00" or "59" |
h | The hour of the day between 1-12. | "1" to "12" |
hh | The hour of the day with leading zero if required. | "01" to "12" |
H | The hour of the day between 0-23. | "0" to "23" |
HH | The hour of the day with leading zero if required. | "00" to "23" |
d | The day of the month between 1 and 31. | "1" to "31" |
dd | The day of the month with leading zero if required. | "01" to "31" |
ddd | Abbreviated day name. Date.!CultureInfo.abbreviatedDayNames. | "Mon" to "Sun" |
dddd | The full day name. Date.!CultureInfo.dayNames. | "Monday" to "Sunday" |
M | The month of the year between 1-12. | "1" to "12" |
MM | The month of the year with leading zero if required. | "01" to "12" |
MMM | Abbreviated month name. Date.!CultureInfo.abbreviatedMonthNames. | "Jan" to "Dec" |
MMMM | The full month name. Date.!CultureInfo.monthNames. | "January" to "December" |
yy | Displays the year as a two-digit number. | "99" or "07" |
yyyy | Displays the full four digit year. | "1999" or "2007" |
t | Displays the first character of the A.M./P.M. designator. Date.!CultureInfo.amDesignator or Date.!CultureInfo.pmDesignator | "A" or "P" |
tt | Displays the A.M./P.M. designator. Date.!CultureInfo.amDesignator or Date.!CultureInfo.pmDesignator | "AM" or "PM" |
S | The ordinal suffix ("st, "nd", "rd" or "th") of the current day. | "st, "nd", "rd" or "th" |
Example:
import { date } from 'pandaman'
console.log(date(new Date())('yyyy年 MM月 dd日')()); // 2019年 04月 09日
// or
console.log(date(new Date())('yyyy年 MM月 dd日').toString());
// or
console.log('' + date(new Date())('yyyy年 MM月 dd日')());
// 柯里化表达
console.log(date(new Date())('yyyy年 MM月 dd日')('柯里化: yy-MMMM-d')()); //2019年 04月 09日柯里化: 19-April-9
被用于格式化的字符(y M d等)不能用于连接符