forked from adamgibbons/ics
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
convert to using dayjs (adamgibbons#146)
* convert to using dayjs * updating license and readme * reverting some changes after receiving email from maintainer * updating package lock Co-authored-by: Adam Gibbons <[email protected]>
- Loading branch information
1 parent
f07225e
commit 18031ed
Showing
10 changed files
with
68 additions
and
62 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,26 @@ | ||
// | ||
// | ||
// DATE-TIME | ||
// FORM #1: DATE WITH LOCAL TIME | ||
// | ||
// | ||
// The date with local time form is simply a DATE-TIME value that | ||
// does not contain the UTC designator nor does it reference a time | ||
// zone. DATE-TIME values of this type are said to be "floating" | ||
// zone. DATE-TIME values of this type are said to be "floating" | ||
// and are not bound to any time zone in particular. | ||
// | ||
// | ||
// For example, the following represents | ||
// January 18, 1998, at 11 PM: | ||
// | ||
// | ||
// 19980118T230000 | ||
// | ||
// | ||
|
||
import moment from 'moment' | ||
import dayjs from 'dayjs' | ||
|
||
export default function formatLocalDateAsLocal(args = []) { | ||
if (args.length > 0) { | ||
const [year, month, date, hours = 0, minutes = 0, seconds = 0] = args | ||
const formattedDate = moment([year, month - 1, date, hours, minutes, seconds]).format('YYYYMMDDTHHmmss') | ||
const formattedDate = dayjs(new Date(year, month - 1, date, hours, minutes, seconds)).format('YYYYMMDDTHHmmss') | ||
return formattedDate | ||
} | ||
|
||
return moment().format('YYYYMMDDTHHmmss') | ||
return dayjs().format('YYYYMMDDTHHmmss') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,37 @@ | ||
// | ||
// | ||
// FORM #2: DATE WITH UTC TIME | ||
// | ||
// | ||
// The date with UTC time, or absolute time, is identified by a LATIN | ||
// CAPITAL LETTER Z suffix character, the UTC designator, appended to | ||
// the time value. For example, the following represents January 19, | ||
// 1998, at 0700 UTC: | ||
// | ||
// | ||
// 19980119T070000Z | ||
// | ||
// | ||
// The "TZID" property parameter MUST NOT be applied to DATE-TIME | ||
// properties whose time values are specified in UTC. | ||
// | ||
// | ||
|
||
import moment from 'moment' | ||
import dayjs from 'dayjs'; | ||
import utc from 'dayjs/plugin/utc'; | ||
|
||
dayjs.extend(utc); | ||
|
||
export default function formatLocalDateAsUTC(args = []) { | ||
if (args.length > 0) { | ||
const [year, month, date, hours = 0, minutes = 0, seconds = 0] = args | ||
|
||
const formattedDate = moment([ | ||
const formattedDate = dayjs(new Date( | ||
year, | ||
month - 1, | ||
date, | ||
hours, | ||
minutes, | ||
seconds | ||
]).utc().format('YYYYMMDDTHHmmss') + 'Z' | ||
)).utc().format('YYYYMMDDTHHmmss') + 'Z' | ||
|
||
return formattedDate | ||
} | ||
|
||
return moment.utc().format('YYYYMMDDTHHmmss') + 'Z' | ||
return dayjs.utc().format('YYYYMMDDTHHmmss') + 'Z' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,29 @@ | ||
// | ||
// | ||
// DATE-TIME | ||
// FORM #1: DATE WITH LOCAL TIME | ||
// | ||
// | ||
// The date with local time form is simply a DATE-TIME value that | ||
// does not contain the UTC designator nor does it reference a time | ||
// zone. DATE-TIME values of this type are said to be "floating" | ||
// zone. DATE-TIME values of this type are said to be "floating" | ||
// and are not bound to any time zone in particular. | ||
// | ||
// | ||
// For example, the following represents | ||
// January 18, 1998, at 11 PM: | ||
// | ||
// | ||
// 19980118T230000 | ||
// | ||
// | ||
|
||
import moment from 'moment' | ||
import dayjs from 'dayjs'; | ||
import utc from 'dayjs/plugin/utc'; | ||
|
||
dayjs.extend(utc); | ||
|
||
export default function formatLocalDateAsLocal(args = []) { | ||
if (args.length > 0) { | ||
const [year, month, date, hours = 0, minutes = 0, seconds = 0] = args | ||
const formattedDate = moment.utc([year, month - 1, date, hours, minutes, seconds]).format('YYYYMMDDTHHmmss') | ||
const formattedDate = dayjs.utc(Date.UTC(year, month - 1, date, hours, minutes, seconds)).format('YYYYMMDDTHHmmss') | ||
return formattedDate | ||
} | ||
|
||
return moment().utc().format('YYYYMMDDTHHmmss') | ||
return dayjs().utc().format('YYYYMMDDTHHmmss') | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,31 @@ | ||
// | ||
// | ||
// FORM #2: DATE WITH UTC TIME | ||
// | ||
// | ||
// The date with UTC time, or absolute time, is identified by a LATIN | ||
// CAPITAL LETTER Z suffix character, the UTC designator, appended to | ||
// the time value. For example, the following represents January 19, | ||
// 1998, at 0700 UTC: | ||
// | ||
// | ||
// 19980119T070000Z | ||
// | ||
// | ||
// The "TZID" property parameter MUST NOT be applied to DATE-TIME | ||
// properties whose time values are specified in UTC. | ||
// | ||
// | ||
|
||
import moment from 'moment' | ||
import dayjs from 'dayjs'; | ||
import utc from 'dayjs/plugin/utc'; | ||
|
||
dayjs.extend(utc); | ||
|
||
export default function formatUTCDateAsUTC(args = []) { | ||
if (args.length > 0) { | ||
const [year, month, date, hours = 0, minutes = 0, seconds = 0] = args | ||
|
||
const formattedDate = moment.utc([ | ||
year, | ||
month - 1, | ||
date, | ||
hours, | ||
minutes, | ||
seconds | ||
]).format('YYYYMMDDTHHmmss') + 'Z' | ||
const formattedDate = dayjs.utc(Date.UTC(year, month - 1, date, hours, minutes, seconds)) | ||
.format('YYYYMMDDTHHmmss') + 'Z' | ||
|
||
return formattedDate | ||
} | ||
|
||
return moment.utc().format('YYYYMMDDTHHmm00') + 'Z' | ||
return dayjs.utc().format('YYYYMMDDTHHmm00') + 'Z' | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters