-
Notifications
You must be signed in to change notification settings - Fork 0
modules
@luke-zhang-04/dateplus / Exports
- addZeros
- daysToHours
- daysToHrs
- daysToMins
- daysToMinutes
- daysToMs
- daysToSeconds
- daysToSecs
- formatDate
- getDateValues
- getElapsedDays
- getElapsedHours
- getElapsedMinutes
- getElapsedMs
- getElapsedSeconds
- getElapsedString
- getUtcTime
- getWordDay
- getWordMonth
- hoursToDays
- hoursToMinutes
- hoursToMs
- hoursToSeconds
- hrsToDays
- hrsToMins
- hrsToMs
- hrsToSecs
- minsToDays
- minsToHrs
- minsToMs
- minsToSecs
- minutesToDays
- minutesToHours
- minutesToMs
- minutesToSeconds
- msToDays
- msToHours
- msToHrs
- msToMins
- msToMinutes
- msToSeconds
- msToSecs
- secondsToDays
- secondsToHours
- secondsToMinutes
- secondsToMs
- secsToDays
- secsToHrs
- secsToMins
- secsToMs
- utcToLocal
Renames and exports: DatePlus
Ƭ DateFormat: "y:m:d"
| "y:d:m"
| "m:d:y"
| "m:y:d"
| "d:m:y"
| "d:y:m"
• Const
daysReference: Object
Reference to days of the week, zero indexed
Name | Type |
---|---|
0 |
string |
1 |
string |
2 |
string |
3 |
string |
4 |
string |
5 |
string |
6 |
string |
• Const
monthsReference: Object
Reference to months of a year, zero indexed
Name | Type |
---|---|
0 |
string |
1 |
string |
10 |
string |
11 |
string |
2 |
string |
3 |
string |
4 |
string |
5 |
string |
6 |
string |
7 |
string |
8 |
string |
9 |
string |
• Const
oneDay: number
One day in ms
• Const
oneHour: number
One hour in ms
• Const
oneMinute: number
One minutes in ms
• Const
values: Object
Name | Type |
---|---|
hrsPerDay |
number |
minsPerHr |
number |
msPerSec |
number |
secsPerMin |
number |
▸ Const
addZeros(date
, seperator?
): string
Add's 0s to date (e.g 2020/4/3 => 2020/04/03)
Name | Type | Default value | Description |
---|---|---|---|
date |
string |
undefined |
String date to format |
seperator |
string |
"/" | Char the date is seperatred by |
string
- Date with zeros
▸ Const
daysToHours(days
): number
Name | Type |
---|---|
days |
number |
number
▸ Const
daysToHrs(days
): number
Converts days to hours
Name | Type | Description |
---|---|---|
days |
number |
Days to convert |
number
Converted hours
▸ Const
daysToMins(days
): number
Converts days to minutes
Name | Type | Description |
---|---|---|
days |
number |
Days to convert |
number
Converted minutes
▸ Const
daysToMinutes(days
): number
Name | Type |
---|---|
days |
number |
number
▸ Const
daysToMs(days
): number
Converts days to milliseconds
Name | Type | Description |
---|---|---|
days |
number |
Days to convert |
number
Converted milliseconds
▸ Const
daysToSeconds(days
): number
Name | Type |
---|---|
days |
number |
number
▸ Const
daysToSecs(days
): number
Converts days to seconds
Name | Type | Description |
---|---|---|
days |
number |
Days to convert |
number
Converted seconds
▸ Const
formatDate(date
, format?
, seperator?
): string
Format date into a string in the form YYYY{seperator}MM{seperator}DD
Name | Type | Default value | Description |
---|---|---|---|
date |
Date |
undefined |
Date object to format |
format |
DateFormat | "y:m:d" | Format of string date |
seperator |
string |
"/" | String to seperate date values with |
string
Formatted date
▸ Const
getDateValues(date
, format?
, seperator?
): YearObj
Gets date values and outputs an object
Name | Type | Default value | Description |
---|---|---|---|
date |
string |
undefined |
Date to extract values from, months zero indexed |
format |
DateFormat | "y:m:d" | Format of string date |
seperator |
string |
"auto" | Seperator the date works with; leave auto for auto detection, limited to 1 char |
Object with all values
▸ Const
getElapsedDays(date1
, date2
): number
Calculates number of elapsed days between date1 and date2
Name | Type | Description |
---|---|---|
date1 |
Date |
Starting date object to calculate |
date2 |
Date |
Ending date object to calculate |
number
- Number of elapsed days
▸ Const
getElapsedHours(date1
, date2
): number
Calculates number of elapsed hours between date1 and date2
Name | Type | Description |
---|---|---|
date1 |
Date |
Starting date object to calculate |
date2 |
Date |
Ending date object to calculate |
number
- Number of elapsed hours
▸ Const
getElapsedMinutes(date1
, date2
): number
Calculates number of elapsed minutes between date1 and date2
Name | Type | Description |
---|---|---|
date1 |
Date |
Starting date object to calculate |
date2 |
Date |
Ending date object to calculate |
number
- Number of elapsed minutes
▸ Const
getElapsedMs(date1
, date2
): number
Calculates number of elapsed milliseconds between date1 and date2
Name | Type | Description |
---|---|---|
date1 |
Date |
Starting date object to calculate |
date2 |
Date |
Ending date object to calculate |
number
- Number of elapsed milliseconds
▸ Const
getElapsedSeconds(date1
, date2
): number
Calculates number of elapsed seconds between date1 and date2
Name | Type | Description |
---|---|---|
date1 |
Date |
Starting date object to calculate |
date2 |
Date |
Ending date object to calculate |
number
- Number of elapsed seconds
▸ Const
getElapsedString(start
, end
, approx?
): string
Calculates elapsed time between current and previous
Name | Type | Default value | Description |
---|---|---|---|
start |
Date |
undefined |
- |
end |
Date |
undefined |
End date |
approx |
string |
"about" | Text to append to values from days and on, e.g about 1 day aga |
string
Time difference in string form, e.g "3 seconds ago"
▸ Const
getUtcTime(): number
Get the current UTC Time
number
UTC Time
▸ Const
getWordDay(numerical
): string
Converts numerical day of week into word form (e.g 0 => "Sunday")
Name | Type | Description |
---|---|---|
numerical |
0 | 1 | 2 | 3 | 4 | 5 | 6
|
Numerical day of week, 0 indexed (0-6) |
string
Stringed day of week
▸ Const
getWordMonth(numerical
): string
Converts numerical month into word form (e.g 0 => "January")
Name | Type | Description |
---|---|---|
numerical |
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11
|
Numerical day of week, 0 indexed (0-11) |
string
Stringed worded month
▸ Const
hoursToDays(hrs
): DaysObj
Name | Type |
---|---|
hrs |
number |
▸ Const
hoursToMinutes(hours
): number
Name | Type |
---|---|
hours |
number |
number
▸ Const
hoursToMs(hours
): number
Name | Type |
---|---|
hours |
number |
number
▸ Const
hoursToSeconds(hours
): number
Name | Type |
---|---|
hours |
number |
number
▸ Const
hrsToDays(hrs
): DaysObj
Converts hours to days with remainders
Name | Type | Description |
---|---|---|
hrs |
number |
Hours to convert |
Converted days
▸ Const
hrsToMins(hours
): number
Converts hours to minutes
Name | Type | Description |
---|---|---|
hours |
number |
Hours to convert |
number
Converted minutes
▸ Const
hrsToMs(hours
): number
Converts hours to milliseconds
Name | Type | Description |
---|---|---|
hours |
number |
Hours to convert |
number
Converted milliseconds
▸ Const
hrsToSecs(hours
): number
Converts hours to seconds
Name | Type | Description |
---|---|---|
hours |
number |
Hours to convert |
number
Converted seconds
▸ Const
minsToDays(mins
): DaysObj
Converts minutes to days with remainders
Name | Type | Description |
---|---|---|
mins |
number |
Minutes to convert |
Converted days
▸ Const
minsToHrs(mins
): HoursObj
Converts minutes to hours with remainders
Name | Type | Description |
---|---|---|
mins |
number |
Minutes to convert |
Converted hours
▸ Const
minsToMs(mins
): number
Converts hours to milliseconds
Name | Type | Description |
---|---|---|
mins |
number |
Minutes to convert |
number
Converted milliseconds
▸ Const
minsToSecs(mins
): number
Converts hours to seconds
Name | Type | Description |
---|---|---|
mins |
number |
Minutes to convert |
number
Converted seconds
▸ Const
minutesToDays(mins
): DaysObj
Name | Type |
---|---|
mins |
number |
▸ Const
minutesToHours(mins
): HoursObj
Name | Type |
---|---|
mins |
number |
▸ Const
minutesToMs(secs
): DaysObj
Name | Type |
---|---|
secs |
number |
▸ Const
minutesToSeconds(mins
): number
Name | Type |
---|---|
mins |
number |
number
▸ Const
msToDays(ms
): DaysObj
Converts milliseconds to days with remainders
Name | Type | Description |
---|---|---|
ms |
number |
Milliseconds to convert |
Object with days, hours, minutes, seconds, and milliseconds
▸ Const
msToHours(ms
): HoursObj
Name | Type |
---|---|
ms |
number |
▸ Const
msToHrs(ms
): HoursObj
Converts milliseconds to hours with remainders
Name | Type | Description |
---|---|---|
ms |
number |
Milliseconds to convert |
Object with hours, minutes, seconds, and milliseconds
▸ Const
msToMins(ms
): MinutesObj
Converts milliseconds to minutes with remainders
Name | Type | Description |
---|---|---|
ms |
number |
Milliseconds to convert |
Object with minutes, seconds, and milliseconds
▸ Const
msToMinutes(ms
): MinutesObj
Name | Type |
---|---|
ms |
number |
▸ Const
msToSeconds(ms
): SecondsObj
Name | Type |
---|---|
ms |
number |
▸ Const
msToSecs(ms
): SecondsObj
Converts milliseconds to seconds with remainders
Name | Type | Description |
---|---|---|
ms |
number |
Milliseconds to convert |
Object with seconds and milliseconds
▸ Const
secondsToDays(secs
): DaysObj
Name | Type |
---|---|
secs |
number |
▸ Const
secondsToHours(secs
): HoursObj
Name | Type |
---|---|
secs |
number |
▸ Const
secondsToMinutes(secs
): MinutesObj
Name | Type |
---|---|
secs |
number |
▸ Const
secondsToMs(secs
): number
Name | Type |
---|---|
secs |
number |
number
▸ Const
secsToDays(secs
): DaysObj
Converts seconds to days with remainders
Name | Type | Description |
---|---|---|
secs |
number |
Seconds to convert |
Converted days
▸ Const
secsToHrs(secs
): HoursObj
Converts seconds to hours with remainders
Name | Type | Description |
---|---|---|
secs |
number |
Seconds to convert |
Converted hours
▸ Const
secsToMins(secs
): MinutesObj
Converts seconds to minutes with remainders
Name | Type | Description |
---|---|---|
secs |
number |
Seconds to convert |
Converted minutes
▸ Const
secsToMs(secs
): number
Converts seconds to milliseconds
Name | Type | Description |
---|---|---|
secs |
number |
Seconds to convert |
number
Converted milliseconds
▸ Const
utcToLocal<T>(date
): T
Convert a utc date to local
Name | Type |
---|---|
T |
T : Date
|
Name | Type | Description |
---|---|---|
date |
T |
Date to use. Note that the parameter will never be mutated. |
T
A new date object with the time converted form UTC
@luke-zhang-04/dateplus / Exports
- addZeros
- daysToHours
- daysToHrs
- daysToMins
- daysToMinutes
- daysToMs
- daysToSeconds
- daysToSecs
- formatDate
- getDateValues
- getElapsedDays
- getElapsedHours
- getElapsedMinutes
- getElapsedMs
- getElapsedSeconds
- getElapsedString
- getUtcTime
- getWordDay
- getWordMonth
- hoursToDays
- hoursToMinutes
- hoursToMs
- hoursToSeconds
- hrsToDays
- hrsToMins
- hrsToMs
- hrsToSecs
- minsToDays
- minsToHrs
- minsToMs
- minsToSecs
- minutesToDays
- minutesToHours
- minutesToMs
- minutesToSeconds
- msToDays
- msToHours
- msToHrs
- msToMins
- msToMinutes
- msToSeconds
- msToSecs
- secondsToDays
- secondsToHours
- secondsToMinutes
- secondsToMs
- secsToDays
- secsToHrs
- secsToMins
- secsToMs
- utcToLocal
Renames and exports: DatePlus
Ƭ DateFormat: "y:m:d"
| "y:d:m"
| "m:d:y"
| "m:y:d"
| "d:m:y"
| "d:y:m"
• Const
daysReference: Object
Reference to days of the week, zero indexed
Name | Type |
---|---|
0 |
string |
1 |
string |
2 |
string |
3 |
string |
4 |
string |
5 |
string |
6 |
string |
• Const
monthsReference: Object
Reference to months of a year, zero indexed
Name | Type |
---|---|
0 |
string |
1 |
string |
10 |
string |
11 |
string |
2 |
string |
3 |
string |
4 |
string |
5 |
string |
6 |
string |
7 |
string |
8 |
string |
9 |
string |
• Const
oneDay: number
One day in ms
• Const
oneHour: number
One hour in ms
• Const
oneMinute: number
One minutes in ms
• Const
values: Object
Name | Type |
---|---|
hrsPerDay |
number |
minsPerHr |
number |
msPerSec |
number |
secsPerMin |
number |
▸ Const
addZeros(date
, seperator?
): string
Add's 0s to date (e.g 2020/4/3 => 2020/04/03)
Name | Type | Default value | Description |
---|---|---|---|
date |
string |
undefined |
String date to format |
seperator |
string |
"/" | Char the date is seperatred by |
string
- Date with zeros
▸ Const
daysToHours(days
): number
Name | Type |
---|---|
days |
number |
number
▸ Const
daysToHrs(days
): number
Converts days to hours
Name | Type | Description |
---|---|---|
days |
number |
Days to convert |
number
Converted hours
▸ Const
daysToMins(days
): number
Converts days to minutes
Name | Type | Description |
---|---|---|
days |
number |
Days to convert |
number
Converted minutes
▸ Const
daysToMinutes(days
): number
Name | Type |
---|---|
days |
number |
number
▸ Const
daysToMs(days
): number
Converts days to milliseconds
Name | Type | Description |
---|---|---|
days |
number |
Days to convert |
number
Converted milliseconds
▸ Const
daysToSeconds(days
): number
Name | Type |
---|---|
days |
number |
number
▸ Const
daysToSecs(days
): number
Converts days to seconds
Name | Type | Description |
---|---|---|
days |
number |
Days to convert |
number
Converted seconds
▸ Const
formatDate(date
, format?
, seperator?
): string
Format date into a string in the form YYYY{seperator}MM{seperator}DD
Name | Type | Default value | Description |
---|---|---|---|
date |
Date |
undefined |
Date object to format |
format |
DateFormat | "y:m:d" | Format of string date |
seperator |
string |
"/" | String to seperate date values with |
string
Formatted date
▸ Const
getDateValues(date
, format?
, seperator?
): YearObj
Gets date values and outputs an object
Name | Type | Default value | Description |
---|---|---|---|
date |
string |
undefined |
Date to extract values from, months zero indexed |
format |
DateFormat | "y:m:d" | Format of string date |
seperator |
string |
"auto" | Seperator the date works with; leave auto for auto detection, limited to 1 char |
Object with all values
▸ Const
getElapsedDays(date1
, date2
): number
Calculates number of elapsed days between date1 and date2
Name | Type | Description |
---|---|---|
date1 |
Date |
Starting date object to calculate |
date2 |
Date |
Ending date object to calculate |
number
- Number of elapsed days
▸ Const
getElapsedHours(date1
, date2
): number
Calculates number of elapsed hours between date1 and date2
Name | Type | Description |
---|---|---|
date1 |
Date |
Starting date object to calculate |
date2 |
Date |
Ending date object to calculate |
number
- Number of elapsed hours
▸ Const
getElapsedMinutes(date1
, date2
): number
Calculates number of elapsed minutes between date1 and date2
Name | Type | Description |
---|---|---|
date1 |
Date |
Starting date object to calculate |
date2 |
Date |
Ending date object to calculate |
number
- Number of elapsed minutes
▸ Const
getElapsedMs(date1
, date2
): number
Calculates number of elapsed milliseconds between date1 and date2
Name | Type | Description |
---|---|---|
date1 |
Date |
Starting date object to calculate |
date2 |
Date |
Ending date object to calculate |
number
- Number of elapsed milliseconds
▸ Const
getElapsedSeconds(date1
, date2
): number
Calculates number of elapsed seconds between date1 and date2
Name | Type | Description |
---|---|---|
date1 |
Date |
Starting date object to calculate |
date2 |
Date |
Ending date object to calculate |
number
- Number of elapsed seconds
▸ Const
getElapsedString(start
, end
, approx?
): string
Calculates elapsed time between current and previous
Name | Type | Default value | Description |
---|---|---|---|
start |
Date |
undefined |
- |
end |
Date |
undefined |
End date |
approx |
string |
"about" | Text to append to values from days and on, e.g about 1 day aga |
string
Time difference in string form, e.g "3 seconds ago"
▸ Const
getUtcTime(): number
Get the current UTC Time
number
UTC Time
▸ Const
getWordDay(numerical
): string
Converts numerical day of week into word form (e.g 0 => "Sunday")
Name | Type | Description |
---|---|---|
numerical |
0 | 1 | 2 | 3 | 4 | 5 | 6
|
Numerical day of week, 0 indexed (0-6) |
string
Stringed day of week
▸ Const
getWordMonth(numerical
): string
Converts numerical month into word form (e.g 0 => "January")
Name | Type | Description |
---|---|---|
numerical |
0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11
|
Numerical day of week, 0 indexed (0-11) |
string
Stringed worded month
▸ Const
hoursToDays(hrs
): DaysObj
Name | Type |
---|---|
hrs |
number |
▸ Const
hoursToMinutes(hours
): number
Name | Type |
---|---|
hours |
number |
number
▸ Const
hoursToMs(hours
): number
Name | Type |
---|---|
hours |
number |
number
▸ Const
hoursToSeconds(hours
): number
Name | Type |
---|---|
hours |
number |
number
▸ Const
hrsToDays(hrs
): DaysObj
Converts hours to days with remainders
Name | Type | Description |
---|---|---|
hrs |
number |
Hours to convert |
Converted days
▸ Const
hrsToMins(hours
): number
Converts hours to minutes
Name | Type | Description |
---|---|---|
hours |
number |
Hours to convert |
number
Converted minutes
▸ Const
hrsToMs(hours
): number
Converts hours to milliseconds
Name | Type | Description |
---|---|---|
hours |
number |
Hours to convert |
number
Converted milliseconds
▸ Const
hrsToSecs(hours
): number
Converts hours to seconds
Name | Type | Description |
---|---|---|
hours |
number |
Hours to convert |
number
Converted seconds
▸ Const
minsToDays(mins
): DaysObj
Converts minutes to days with remainders
Name | Type | Description |
---|---|---|
mins |
number |
Minutes to convert |
Converted days
▸ Const
minsToHrs(mins
): HoursObj
Converts minutes to hours with remainders
Name | Type | Description |
---|---|---|
mins |
number |
Minutes to convert |
Converted hours
▸ Const
minsToMs(mins
): number
Converts hours to milliseconds
Name | Type | Description |
---|---|---|
mins |
number |
Minutes to convert |
number
Converted milliseconds
▸ Const
minsToSecs(mins
): number
Converts hours to seconds
Name | Type | Description |
---|---|---|
mins |
number |
Minutes to convert |
number
Converted seconds
▸ Const
minutesToDays(mins
): DaysObj
Name | Type |
---|---|
mins |
number |
▸ Const
minutesToHours(mins
): HoursObj
Name | Type |
---|---|
mins |
number |
▸ Const
minutesToMs(secs
): DaysObj
Name | Type |
---|---|
secs |
number |
▸ Const
minutesToSeconds(mins
): number
Name | Type |
---|---|
mins |
number |
number
▸ Const
msToDays(ms
): DaysObj
Converts milliseconds to days with remainders
Name | Type | Description |
---|---|---|
ms |
number |
Milliseconds to convert |
Object with days, hours, minutes, seconds, and milliseconds
▸ Const
msToHours(ms
): HoursObj
Name | Type |
---|---|
ms |
number |
▸ Const
msToHrs(ms
): HoursObj
Converts milliseconds to hours with remainders
Name | Type | Description |
---|---|---|
ms |
number |
Milliseconds to convert |
Object with hours, minutes, seconds, and milliseconds
▸ Const
msToMins(ms
): MinutesObj
Converts milliseconds to minutes with remainders
Name | Type | Description |
---|---|---|
ms |
number |
Milliseconds to convert |
Object with minutes, seconds, and milliseconds
▸ Const
msToMinutes(ms
): MinutesObj
Name | Type |
---|---|
ms |
number |
▸ Const
msToSeconds(ms
): SecondsObj
Name | Type |
---|---|
ms |
number |
▸ Const
msToSecs(ms
): SecondsObj
Converts milliseconds to seconds with remainders
Name | Type | Description |
---|---|---|
ms |
number |
Milliseconds to convert |
Object with seconds and milliseconds
▸ Const
secondsToDays(secs
): DaysObj
Name | Type |
---|---|
secs |
number |
▸ Const
secondsToHours(secs
): HoursObj
Name | Type |
---|---|
secs |
number |
▸ Const
secondsToMinutes(secs
): MinutesObj
Name | Type |
---|---|
secs |
number |
▸ Const
secondsToMs(secs
): number
Name | Type |
---|---|
secs |
number |
number
▸ Const
secsToDays(secs
): DaysObj
Converts seconds to days with remainders
Name | Type | Description |
---|---|---|
secs |
number |
Seconds to convert |
Converted days
▸ Const
secsToHrs(secs
): HoursObj
Converts seconds to hours with remainders
Name | Type | Description |
---|---|---|
secs |
number |
Seconds to convert |
Converted hours
▸ Const
secsToMins(secs
): MinutesObj
Converts seconds to minutes with remainders
Name | Type | Description |
---|---|---|
secs |
number |
Seconds to convert |
Converted minutes
▸ Const
secsToMs(secs
): number
Converts seconds to milliseconds
Name | Type | Description |
---|---|---|
secs |
number |
Seconds to convert |
number
Converted milliseconds
▸ Const
utcToLocal<T>(date
): T
Convert a utc date to local
Name | Type |
---|---|
T |
T : Date
|
Name | Type | Description |
---|---|---|
date |
T |
Date to use. Note that the parameter will never be mutated. |
T
A new date object with the time converted form UTC