Gathering detailed insights and metrics for date-format-parse
Gathering detailed insights and metrics for date-format-parse
Gathering detailed insights and metrics for date-format-parse
Gathering detailed insights and metrics for date-format-parse
npm install date-format-parse
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
14 Stars
35 Commits
11 Forks
3 Watching
16 Branches
2 Contributors
Updated on 14 May 2024
TypeScript (93.64%)
JavaScript (4.93%)
Shell (1.43%)
Cumulative downloads
Total Downloads
Last day
-11.3%
19,290
Compared to previous day
Last week
-1.7%
107,771
Compared to previous week
Last month
7.3%
457,563
Compared to previous month
Last year
3.9%
5,197,303
Compared to previous year
26
Lightweight date format and parse. Meant to replace the primary functions of format and parse of momentjs.
1$ npm install date-format-parse --save
Format Date to String.
1import { format } from 'date-format-parse'; 2 3format(new Date(), 'YYYY-MM-DD HH:mm:ss.SSS'); 4 5// with locale, see locale config below 6const obj = { ... } 7 8format(new Date(), 'YYYY-MM-DD', { locale: obj }) 9
Parse String to Date
1import { parse } from 'date-format-parse'; 2 3parse('2019-12-10 14:11:12', 'YYYY-MM-DD HH:mm:ss'); // new Date(2019, 11, 10, 14, 11, 12) 4 5// with backupDate, default is new Date() 6parse('10:00', 'HH:mm', { backupDate: new Date(2019, 5, 6) }) // new Date(2019, 5, 6, 10) 7 8// with locale, see locale config below 9const obj = { ... } 10 11parse('2019-12-10 14:11:12', 'YYYY-MM-DD HH:mm:ss', { locale: obj }); 12
1interface Locale { 2 months: string[]; 3 monthsShort: string[]; 4 weekdays: string[]; 5 weekdaysShort: string[]; 6 weekdaysMin: string[]; 7 meridiem?: (hours: number, minutes: number, isLowercase: boolean) => string; 8 meridiemParse?: RegExp; 9 isPM?: (input: string) => boolean; 10 ordinal?: () => string; 11} 12 13const locale = { 14 // MMMM 15 months: [ 16 'January', 17 'February', 18 'March', 19 'April', 20 'May', 21 'June', 22 'July', 23 'August', 24 'September', 25 'October', 26 'November', 27 'December', 28 ], 29 // MMM 30 monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'], 31 // dddd 32 weekdays: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], 33 // ddd 34 weekdaysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'], 35 // dd 36 weekdaysMin: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'], 37 // [A a] format the ampm. The following is the default value 38 meridiem: (h: number, m: number, isLowercase: boolean) => { 39 const word = h < 12 ? 'AM' : 'PM'; 40 return isLowercase ? word.toLocaleLowerCase() : word; 41 }; 42 // [A a] used by parse to match the ampm. The following is the default value 43 meridiemParse: /[ap]\.?m?\.?/i, 44 // [A a] used by parse to determine if the matching string is pm. The following is the default value 45 isPM: (input) => { 46 return (input + '').toLowerCase().charAt(0) === 'p'; 47 } 48};
Uint | Token | output |
---|---|---|
Year | YY | 70 71 ... 10 11 |
YYYY | 1970 1971 ... 2010 2011 | |
Month | M | 1 2 ... 11 12 |
MM | 01 02 ... 11 12 | |
MMM | Jan Feb ... Nov Dec | |
MMMM | January February ... November December | |
Day of Month | D | 1 2 ... 30 31 |
DD | 01 02 ... 30 31 | |
Day of Week | d | 0 1 ... 5 6 |
dd | Su Mo ... Fr Sa | |
ddd | Sun Mon ... Fri Sat | |
dddd | Sunday Monday ... Friday Saturday | |
AM/PM | A | AM PM |
a | am pm | |
Hour | H | 0 1 ... 22 23 |
HH | 00 01 ... 22 23 | |
h | 1 2 ... 12 | |
hh | 01 02 ... 12 | |
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 | |
Time Zone | Z | -07:00 -06:00 ... +06:00 +07:00 |
ZZ | -0700 -0600 ... +0600 +0700 | |
Week of Year | w | 1 2 ... 52 53 |
ww | 01 02 ... 52 53 | |
Unix Timestamp | X | 1360013296 |
Unix Millisecond Timestamp | x | 1360013296123 |
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/29 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
52 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More