dayjs
Advanced tools
Comparing version 1.10.3 to 1.10.4
@@ -0,1 +1,14 @@ | ||
## [1.10.4](https://github.com/iamkun/dayjs/compare/v1.10.3...v1.10.4) (2021-01-22) | ||
### Bug Fixes | ||
* Correct handling negative duration ([#1317](https://github.com/iamkun/dayjs/issues/1317)) ([3f5c085](https://github.com/iamkun/dayjs/commit/3f5c085608182472f20b84766b10949945663e44)) | ||
* Improve `Duration` types ([#1338](https://github.com/iamkun/dayjs/issues/1338)) ([4aca4b1](https://github.com/iamkun/dayjs/commit/4aca4b1b584a15de1146d929f95c944594032f20)) | ||
* parse a string for MMM month format with underscore delimiter ([#1349](https://github.com/iamkun/dayjs/issues/1349)) ([82ef9a3](https://github.com/iamkun/dayjs/commit/82ef9a304f06287ac0a14c4da9a7fe6152b5fec9)) | ||
* Update Bengali [bn] locale ([#1329](https://github.com/iamkun/dayjs/issues/1329)) ([02d96ec](https://github.com/iamkun/dayjs/commit/02d96ec7189f62d6ef8987135919cbb5ceff20a6)) | ||
* update locale Portuguese [pt] yearStart ([#1345](https://github.com/iamkun/dayjs/issues/1345)) ([5c785d5](https://github.com/iamkun/dayjs/commit/5c785d528cc08811638d7cbfc7fc158d67b32d75)) | ||
* update Polish [pl] locale yearStart ([#1348](https://github.com/iamkun/dayjs/issues/1348)) ([e93e6b8](https://github.com/iamkun/dayjs/commit/e93e6b8ffa61036b26382f1763e3864d4a7d5df5)) | ||
* Update Slovenian [sl] relativeTime locale ([#1333](https://github.com/iamkun/dayjs/issues/1333)) ([fe5f1d0](https://github.com/iamkun/dayjs/commit/fe5f1d0afbe57b70339e268047e6c3028ca3d59b)) | ||
## [1.10.3](https://github.com/iamkun/dayjs/compare/v1.10.2...v1.10.3) (2021-01-09) | ||
@@ -2,0 +15,0 @@ |
@@ -16,7 +16,7 @@ /// <reference path="./locale/index.d.ts" /> | ||
type UnitTypeShort = 'd' | 'M' | 'y' | 'h' | 'm' | 's' | 'ms' | ||
export type UnitTypeShort = 'd' | 'M' | 'y' | 'h' | 'm' | 's' | 'ms' | ||
type UnitTypeLong = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' | 'date' | ||
export type UnitTypeLong = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' | 'date' | ||
type UnitTypeLongPlural = 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'years' | 'dates' | ||
export type UnitTypeLongPlural = 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'years' | 'dates' | ||
@@ -23,0 +23,0 @@ export type UnitType = UnitTypeLong | UnitTypeLongPlural | UnitTypeShort; |
// Bengali [bn] | ||
import dayjs from '../index'; | ||
var symbolMap = { | ||
1: '১', | ||
2: '২', | ||
3: '৩', | ||
4: '৪', | ||
5: '৫', | ||
6: '৬', | ||
7: '৭', | ||
8: '৮', | ||
9: '৯', | ||
0: '০' | ||
}; | ||
var numberMap = { | ||
'১': '1', | ||
'২': '2', | ||
'৩': '3', | ||
'৪': '4', | ||
'৫': '5', | ||
'৬': '6', | ||
'৭': '7', | ||
'৮': '8', | ||
'৯': '9', | ||
'০': '0' | ||
}; | ||
var locale = { | ||
name: 'bn', | ||
weekdays: 'রবিবার_সোমবার_মঙ্গলবার_বুধবার_বৃহস্পতিবার_শুক্রবার_শনিবার'.split('_'), | ||
months: 'জানুয়ারী_ফেব্রুয়ারি_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর'.split('_'), | ||
months: 'জানুয়ারি_ফেব্রুয়ারি_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর'.split('_'), | ||
weekdaysShort: 'রবি_সোম_মঙ্গল_বুধ_বৃহস্পতি_শুক্র_শনি'.split('_'), | ||
monthsShort: 'জানু_ফেব_মার্চ_এপ্র_মে_জুন_জুল_আগ_সেপ্ট_অক্টো_নভে_ডিসে'.split('_'), | ||
weekdaysMin: 'রবি_সোম_মঙ্গ_বুধ_বৃহঃ_শুক্র_শনি'.split('_'), | ||
preparse: function preparse(string) { | ||
return string.replace(/[১২৩৪৫৬৭৮৯০]/g, function (match) { | ||
return numberMap[match]; | ||
}); | ||
}, | ||
postformat: function postformat(string) { | ||
return string.replace(/\d/g, function (match) { | ||
return symbolMap[match]; | ||
}); | ||
}, | ||
ordinal: function ordinal(n) { | ||
@@ -11,0 +45,0 @@ return n; |
@@ -61,2 +61,3 @@ // Polish [pl] | ||
weekStart: 1, | ||
yearStart: 4, | ||
relativeTime: { | ||
@@ -63,0 +64,0 @@ future: 'za %s', |
@@ -14,2 +14,3 @@ // Portuguese [pt] | ||
weekStart: 1, | ||
yearStart: 4, | ||
formats: { | ||
@@ -16,0 +17,0 @@ LT: 'HH:mm', |
@@ -21,2 +21,17 @@ // Slovenian [sl] | ||
LLLL: 'dddd, D. MMMM YYYY H:mm' | ||
}, | ||
relativeTime: { | ||
future: 'čez %s', | ||
past: 'pred %s', | ||
s: 'nekaj sekund', | ||
m: 'minuta', | ||
mm: '%d minut', | ||
h: 'ura', | ||
hh: '%d ur', | ||
d: 'dan', | ||
dd: '%d dni', | ||
M: 'mesec', | ||
MM: '%d mesecev', | ||
y: 'leto', | ||
yy: '%d let' | ||
} | ||
@@ -23,0 +38,0 @@ }; |
@@ -17,3 +17,3 @@ import { u } from '../localizedFormat/utils'; | ||
var matchWord = /\d*[^\s\d-:/()]+/; // Word | ||
var matchWord = /\d*[^\s\d-_:/()]+/; // Word | ||
@@ -20,0 +20,0 @@ var locale = {}; |
import { PluginFunc } from 'dayjs/esm' | ||
import { OpUnitType, UnitTypeLongPlural } from "../index"; | ||
@@ -8,7 +9,13 @@ declare const plugin: PluginFunc | ||
declare namespace plugin { | ||
type DurationInputType = string | number | object | ||
type DurationAddType = number | object | Duration | ||
type DurationUnitsObjectType = Partial<{ | ||
[unit in Exclude<UnitTypeLongPlural, "dates"> | "weeks"]: number | ||
}>; | ||
type DurationUnitType = Exclude<OpUnitType, "date" | "dates"> | ||
type CreateDurationType = | ||
((units: DurationUnitsObjectType) => Duration) | ||
& ((time: number, unit?: DurationUnitType) => Duration) | ||
& ((ISO_8601: string) => Duration) | ||
interface Duration { | ||
new (input: DurationInputType, unit?: string, locale?: string): Duration | ||
new (input: string | number | object, unit?: string, locale?: string): Duration | ||
@@ -43,10 +50,10 @@ clone(): Duration | ||
as(unit: string): number | ||
as(unit: DurationUnitType): number | ||
get(unit: string): number | ||
get(unit: DurationUnitType): number | ||
add(input: DurationAddType, unit? : string): Duration | ||
add: CreateDurationType; | ||
subtract: CreateDurationType | ||
subtract(input: DurationAddType, unit? : string): Duration | ||
toJSON(): string | ||
@@ -64,8 +71,11 @@ | ||
interface Dayjs { | ||
add(value: plugin.Duration): Dayjs | ||
subtract(value: plugin.Duration): Dayjs | ||
add(duration: plugin.Duration): Dayjs | ||
subtract(duration: plugin.Duration): Dayjs | ||
} | ||
export function duration(input?: plugin.DurationInputType , unit?: string): plugin.Duration | ||
/** | ||
* @param time If unit is not present, time treated as number of milliseconds | ||
*/ | ||
export const duration: plugin.CreateDurationType; | ||
export function isDuration(d: any): d is plugin.Duration | ||
} |
@@ -33,2 +33,35 @@ import { MILLISECONDS_A_DAY, MILLISECONDS_A_HOUR, MILLISECONDS_A_MINUTE, MILLISECONDS_A_SECOND, MILLISECONDS_A_WEEK, REGEX_FORMAT } from '../../constant'; | ||
var isNegative = function isNegative(number) { | ||
return number < 0; | ||
}; | ||
var roundNumber = function roundNumber(number) { | ||
return isNegative(number) ? Math.ceil(number) : Math.floor(number); | ||
}; | ||
var absolute = function absolute(number) { | ||
return Math.abs(number); | ||
}; | ||
var getNumberUnitFormat = function getNumberUnitFormat(number, unit) { | ||
if (!number) { | ||
return { | ||
negative: false, | ||
format: '' | ||
}; | ||
} | ||
if (isNegative(number)) { | ||
return { | ||
negative: true, | ||
format: "" + absolute(number) + unit | ||
}; | ||
} | ||
return { | ||
negative: false, | ||
format: "" + number + unit | ||
}; | ||
}; | ||
var Duration = /*#__PURE__*/function () { | ||
@@ -90,13 +123,13 @@ function Duration(input, unit, locale) { | ||
var $ms = this.$ms; | ||
this.$d.years = Math.floor($ms / MILLISECONDS_A_YEAR); | ||
this.$d.years = roundNumber($ms / MILLISECONDS_A_YEAR); | ||
$ms %= MILLISECONDS_A_YEAR; | ||
this.$d.months = Math.floor($ms / MILLISECONDS_A_MONTH); | ||
this.$d.months = roundNumber($ms / MILLISECONDS_A_MONTH); | ||
$ms %= MILLISECONDS_A_MONTH; | ||
this.$d.days = Math.floor($ms / MILLISECONDS_A_DAY); | ||
this.$d.days = roundNumber($ms / MILLISECONDS_A_DAY); | ||
$ms %= MILLISECONDS_A_DAY; | ||
this.$d.hours = Math.floor($ms / MILLISECONDS_A_HOUR); | ||
this.$d.hours = roundNumber($ms / MILLISECONDS_A_HOUR); | ||
$ms %= MILLISECONDS_A_HOUR; | ||
this.$d.minutes = Math.floor($ms / MILLISECONDS_A_MINUTE); | ||
this.$d.minutes = roundNumber($ms / MILLISECONDS_A_MINUTE); | ||
$ms %= MILLISECONDS_A_MINUTE; | ||
this.$d.seconds = Math.floor($ms / MILLISECONDS_A_SECOND); | ||
this.$d.seconds = roundNumber($ms / MILLISECONDS_A_SECOND); | ||
$ms %= MILLISECONDS_A_SECOND; | ||
@@ -107,4 +140,4 @@ this.$d.milliseconds = $ms; | ||
_proto.toISOString = function toISOString() { | ||
var Y = this.$d.years ? this.$d.years + "Y" : ''; | ||
var M = this.$d.months ? this.$d.months + "M" : ''; | ||
var Y = getNumberUnitFormat(this.$d.years, 'Y'); | ||
var M = getNumberUnitFormat(this.$d.months, 'M'); | ||
var days = +this.$d.days || 0; | ||
@@ -116,5 +149,5 @@ | ||
var D = days ? days + "D" : ''; | ||
var H = this.$d.hours ? this.$d.hours + "H" : ''; | ||
var m = this.$d.minutes ? this.$d.minutes + "M" : ''; | ||
var D = getNumberUnitFormat(days, 'D'); | ||
var H = getNumberUnitFormat(this.$d.hours, 'H'); | ||
var m = getNumberUnitFormat(this.$d.minutes, 'M'); | ||
var seconds = this.$d.seconds || 0; | ||
@@ -126,6 +159,8 @@ | ||
var S = seconds ? seconds + "S" : ''; | ||
var T = H || m || S ? 'T' : ''; | ||
var result = "P" + Y + M + D + T + H + m + S; | ||
return result === 'P' ? 'P0D' : result; | ||
var S = getNumberUnitFormat(seconds, 'S'); | ||
var negativeMode = Y.negative || M.negative || D.negative || H.negative || m.negative || S.negative; | ||
var T = H.format || m.format || S.format ? 'T' : ''; | ||
var P = negativeMode ? '-' : ''; | ||
var result = P + "P" + Y.format + M.format + D.format + T + H.format + m.format + S.format; | ||
return result === 'P' || result === '-P' ? 'P0D' : result; | ||
}; | ||
@@ -171,3 +206,3 @@ | ||
} else if (pUnit === 'weeks') { | ||
base = Math.floor(base / unitToMS[pUnit]); | ||
base = roundNumber(base / unitToMS[pUnit]); | ||
} else { | ||
@@ -177,3 +212,3 @@ base = this.$d[pUnit]; | ||
return base; | ||
return base === 0 ? 0 : base; // a === 0 will be true on both 0 and -0 | ||
}; | ||
@@ -180,0 +215,0 @@ |
@@ -16,7 +16,7 @@ /// <reference path="./locale/index.d.ts" /> | ||
type UnitTypeShort = 'd' | 'M' | 'y' | 'h' | 'm' | 's' | 'ms' | ||
export type UnitTypeShort = 'd' | 'M' | 'y' | 'h' | 'm' | 's' | 'ms' | ||
type UnitTypeLong = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' | 'date' | ||
export type UnitTypeLong = 'millisecond' | 'second' | 'minute' | 'hour' | 'day' | 'month' | 'year' | 'date' | ||
type UnitTypeLongPlural = 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'years' | 'dates' | ||
export type UnitTypeLongPlural = 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'months' | 'years' | 'dates' | ||
@@ -23,0 +23,0 @@ export type UnitType = UnitTypeLong | UnitTypeLongPlural | UnitTypeShort; |
@@ -1,1 +0,1 @@ | ||
!function(_,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e(require("dayjs")):"function"==typeof define&&define.amd?define(["dayjs"],e):_.dayjs_locale_bn=e(_.dayjs)}(this,function(_){"use strict";_=_&&_.hasOwnProperty("default")?_.default:_;var e={name:"bn",weekdays:"রবিবার_সোমবার_মঙ্গলবার_বুধবার_বৃহস্পতিবার_শুক্রবার_শনিবার".split("_"),months:"জানুয়ারী_ফেব্রুয়ারি_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর".split("_"),weekdaysShort:"রবি_সোম_মঙ্গল_বুধ_বৃহস্পতি_শুক্র_শনি".split("_"),monthsShort:"জানু_ফেব_মার্চ_এপ্র_মে_জুন_জুল_আগ_সেপ্ট_অক্টো_নভে_ডিসে".split("_"),weekdaysMin:"রবি_সোম_মঙ্গ_বুধ_বৃহঃ_শুক্র_শনি".split("_"),ordinal:function(_){return _},formats:{LT:"A h:mm সময়",LTS:"A h:mm:ss সময়",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm সময়",LLLL:"dddd, D MMMM YYYY, A h:mm সময়"},relativeTime:{future:"%s পরে",past:"%s আগে",s:"কয়েক সেকেন্ড",m:"এক মিনিট",mm:"%d মিনিট",h:"এক ঘন্টা",hh:"%d ঘন্টা",d:"এক দিন",dd:"%d দিন",M:"এক মাস",MM:"%d মাস",y:"এক বছর",yy:"%d বছর"}};return _.locale(e,null,!0),e}); | ||
!function(e,_){"object"==typeof exports&&"undefined"!=typeof module?module.exports=_(require("dayjs")):"function"==typeof define&&define.amd?define(["dayjs"],_):e.dayjs_locale_bn=_(e.dayjs)}(this,function(e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var _={1:"১",2:"২",3:"৩",4:"৪",5:"৫",6:"৬",7:"৭",8:"৮",9:"৯",0:"০"},t={"১":"1","২":"2","৩":"3","৪":"4","৫":"5","৬":"6","৭":"7","৮":"8","৯":"9","০":"0"},n={name:"bn",weekdays:"রবিবার_সোমবার_মঙ্গলবার_বুধবার_বৃহস্পতিবার_শুক্রবার_শনিবার".split("_"),months:"জানুয়ারি_ফেব্রুয়ারি_মার্চ_এপ্রিল_মে_জুন_জুলাই_আগস্ট_সেপ্টেম্বর_অক্টোবর_নভেম্বর_ডিসেম্বর".split("_"),weekdaysShort:"রবি_সোম_মঙ্গল_বুধ_বৃহস্পতি_শুক্র_শনি".split("_"),monthsShort:"জানু_ফেব_মার্চ_এপ্র_মে_জুন_জুল_আগ_সেপ্ট_অক্টো_নভে_ডিসে".split("_"),weekdaysMin:"রবি_সোম_মঙ্গ_বুধ_বৃহঃ_শুক্র_শনি".split("_"),preparse:function(e){return e.replace(/[১২৩৪৫৬৭৮৯০]/g,function(e){return t[e]})},postformat:function(e){return e.replace(/\d/g,function(e){return _[e]})},ordinal:function(e){return e},formats:{LT:"A h:mm সময়",LTS:"A h:mm:ss সময়",L:"DD/MM/YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY, A h:mm সময়",LLLL:"dddd, D MMMM YYYY, A h:mm সময়"},relativeTime:{future:"%s পরে",past:"%s আগে",s:"কয়েক সেকেন্ড",m:"এক মিনিট",mm:"%d মিনিট",h:"এক ঘন্টা",hh:"%d ঘন্টা",d:"এক দিন",dd:"%d দিন",M:"এক মাস",MM:"%d মাস",y:"এক বছর",yy:"%d বছর"}};return e.locale(n,null,!0),n}); |
@@ -1,1 +0,1 @@ | ||
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?module.exports=i(require("dayjs")):"function"==typeof define&&define.amd?define(["dayjs"],i):e.dayjs_locale_pl=i(e.dayjs)}(this,function(e){"use strict";function i(e){return e%10<5&&e%10>1&&~~(e/10)%10!=1}function t(e,t,a){var n=e+" ";switch(a){case"m":return t?"minuta":"minutę";case"mm":return n+(i(e)?"minuty":"minut");case"h":return t?"godzina":"godzinę";case"hh":return n+(i(e)?"godziny":"godzin");case"MM":return n+(i(e)?"miesiące":"miesięcy");case"yy":return n+(i(e)?"lata":"lat")}}e=e&&e.hasOwnProperty("default")?e.default:e;var a="stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia".split("_"),n="styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień".split("_"),_=/D MMMM/,r=function(e,i){return _.test(i)?a[e.month()]:n[e.month()]};r.s=n,r.f=a;var s={name:"pl",weekdays:"niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota".split("_"),weekdaysShort:"ndz_pon_wt_śr_czw_pt_sob".split("_"),weekdaysMin:"Nd_Pn_Wt_Śr_Cz_Pt_So".split("_"),months:r,monthsShort:"sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru".split("_"),ordinal:function(e){return e+"."},weekStart:1,relativeTime:{future:"za %s",past:"%s temu",s:"kilka sekund",m:t,mm:t,h:t,hh:t,d:"1 dzień",dd:"%d dni",M:"miesiąc",MM:t,y:"rok",yy:t},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return e.locale(s,null,!0),s}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("dayjs")):"function"==typeof define&&define.amd?define(["dayjs"],t):e.dayjs_locale_pl=t(e.dayjs)}(this,function(e){"use strict";function t(e){return e%10<5&&e%10>1&&~~(e/10)%10!=1}function i(e,i,a){var n=e+" ";switch(a){case"m":return i?"minuta":"minutę";case"mm":return n+(t(e)?"minuty":"minut");case"h":return i?"godzina":"godzinę";case"hh":return n+(t(e)?"godziny":"godzin");case"MM":return n+(t(e)?"miesiące":"miesięcy");case"yy":return n+(t(e)?"lata":"lat")}}e=e&&e.hasOwnProperty("default")?e.default:e;var a="stycznia_lutego_marca_kwietnia_maja_czerwca_lipca_sierpnia_września_października_listopada_grudnia".split("_"),n="styczeń_luty_marzec_kwiecień_maj_czerwiec_lipiec_sierpień_wrzesień_październik_listopad_grudzień".split("_"),r=/D MMMM/,_=function(e,t){return r.test(t)?a[e.month()]:n[e.month()]};_.s=n,_.f=a;var s={name:"pl",weekdays:"niedziela_poniedziałek_wtorek_środa_czwartek_piątek_sobota".split("_"),weekdaysShort:"ndz_pon_wt_śr_czw_pt_sob".split("_"),weekdaysMin:"Nd_Pn_Wt_Śr_Cz_Pt_So".split("_"),months:_,monthsShort:"sty_lut_mar_kwi_maj_cze_lip_sie_wrz_paź_lis_gru".split("_"),ordinal:function(e){return e+"."},weekStart:1,yearStart:4,relativeTime:{future:"za %s",past:"%s temu",s:"kilka sekund",m:i,mm:i,h:i,hh:i,d:"1 dzień",dd:"%d dni",M:"miesiąc",MM:i,y:"rok",yy:i},formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD.MM.YYYY",LL:"D MMMM YYYY",LLL:"D MMMM YYYY HH:mm",LLLL:"dddd, D MMMM YYYY HH:mm"}};return e.locale(s,null,!0),s}); |
@@ -1,1 +0,1 @@ | ||
!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?module.exports=a(require("dayjs")):"function"==typeof define&&define.amd?define(["dayjs"],a):e.dayjs_locale_pt=a(e.dayjs)}(this,function(e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var a={name:"pt",weekdays:"Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado".split("_"),weekdaysShort:"Dom_Seg_Ter_Qua_Qui_Sex_Sab".split("_"),weekdaysMin:"Do_2ª_3ª_4ª_5ª_6ª_Sa".split("_"),months:"Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro".split("_"),monthsShort:"Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez".split("_"),ordinal:function(e){return e+"º"},weekStart:1,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY [às] HH:mm",LLLL:"dddd, D [de] MMMM [de] YYYY [às] HH:mm"},relativeTime:{future:"em %s",past:"há %s",s:"alguns segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um mês",MM:"%d meses",y:"um ano",yy:"%d anos"}};return e.locale(a,null,!0),a}); | ||
!function(e,a){"object"==typeof exports&&"undefined"!=typeof module?module.exports=a(require("dayjs")):"function"==typeof define&&define.amd?define(["dayjs"],a):e.dayjs_locale_pt=a(e.dayjs)}(this,function(e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var a={name:"pt",weekdays:"Domingo_Segunda-feira_Terça-feira_Quarta-feira_Quinta-feira_Sexta-feira_Sábado".split("_"),weekdaysShort:"Dom_Seg_Ter_Qua_Qui_Sex_Sab".split("_"),weekdaysMin:"Do_2ª_3ª_4ª_5ª_6ª_Sa".split("_"),months:"Janeiro_Fevereiro_Março_Abril_Maio_Junho_Julho_Agosto_Setembro_Outubro_Novembro_Dezembro".split("_"),monthsShort:"Jan_Fev_Mar_Abr_Mai_Jun_Jul_Ago_Set_Out_Nov_Dez".split("_"),ordinal:function(e){return e+"º"},weekStart:1,yearStart:4,formats:{LT:"HH:mm",LTS:"HH:mm:ss",L:"DD/MM/YYYY",LL:"D [de] MMMM [de] YYYY",LLL:"D [de] MMMM [de] YYYY [às] HH:mm",LLLL:"dddd, D [de] MMMM [de] YYYY [às] HH:mm"},relativeTime:{future:"em %s",past:"há %s",s:"alguns segundos",m:"um minuto",mm:"%d minutos",h:"uma hora",hh:"%d horas",d:"um dia",dd:"%d dias",M:"um mês",MM:"%d meses",y:"um ano",yy:"%d anos"}};return e.locale(a,null,!0),a}); |
@@ -1,1 +0,1 @@ | ||
!function(e,_){"object"==typeof exports&&"undefined"!=typeof module?module.exports=_(require("dayjs")):"function"==typeof define&&define.amd?define(["dayjs"],_):e.dayjs_locale_sl=_(e.dayjs)}(this,function(e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var _={name:"sl",weekdays:"nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota".split("_"),months:"januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december".split("_"),weekStart:1,weekdaysShort:"ned._pon._tor._sre._čet._pet._sob.".split("_"),monthsShort:"jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.".split("_"),weekdaysMin:"ne_po_to_sr_če_pe_so".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"}};return e.locale(_,null,!0),_}); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t(require("dayjs")):"function"==typeof define&&define.amd?define(["dayjs"],t):e.dayjs_locale_sl=t(e.dayjs)}(this,function(e){"use strict";e=e&&e.hasOwnProperty("default")?e.default:e;var t={name:"sl",weekdays:"nedelja_ponedeljek_torek_sreda_četrtek_petek_sobota".split("_"),months:"januar_februar_marec_april_maj_junij_julij_avgust_september_oktober_november_december".split("_"),weekStart:1,weekdaysShort:"ned._pon._tor._sre._čet._pet._sob.".split("_"),monthsShort:"jan._feb._mar._apr._maj._jun._jul._avg._sep._okt._nov._dec.".split("_"),weekdaysMin:"ne_po_to_sr_če_pe_so".split("_"),ordinal:function(e){return e},formats:{LT:"H:mm",LTS:"H:mm:ss",L:"DD.MM.YYYY",LL:"D. MMMM YYYY",LLL:"D. MMMM YYYY H:mm",LLLL:"dddd, D. MMMM YYYY H:mm"},relativeTime:{future:"čez %s",past:"pred %s",s:"nekaj sekund",m:"minuta",mm:"%d minut",h:"ura",hh:"%d ur",d:"dan",dd:"%d dni",M:"mesec",MM:"%d mesecev",y:"leto",yy:"%d let"}};return e.locale(t,null,!0),t}); |
{ | ||
"name": "dayjs", | ||
"version": "1.10.3", | ||
"version": "1.10.4", | ||
"description": "2KB immutable date time library alternative to Moment.js with the same modern API ", | ||
@@ -5,0 +5,0 @@ "main": "dayjs.min.js", |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.dayjs_plugin_customParseFormat=e()}(this,function(){"use strict";var t={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},e=function(e,n){return e.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(e,r,i){var o=i&&i.toUpperCase();return r||n[i]||t[i]||n[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(t,e,n){return e||n.slice(1)})})},n=/(\[[^[]*\])|([-:/.()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,r=/\d\d/,i=/\d\d?/,o=/\d*[^\s\d-:/()]+/,s={};var a=function(t){return function(e){this[t]=+e}},f=[/[+-]\d\d:?(\d\d)?/,function(t){(this.zone||(this.zone={})).offset=function(t){if(!t)return 0;var e=t.match(/([+-]|\d\d)/g),n=60*e[1]+(+e[2]||0);return 0===n?0:"+"===e[0]?-n:n}(t)}],u=function(t){var e=s[t];return e&&(e.indexOf?e:e.s.concat(e.f))},h=function(t,e){var n,r=s.meridiem;if(r){for(var i=1;i<=24;i+=1)if(t.indexOf(r(i,0,e))>-1){n=i>12;break}}else n=t===(e?"pm":"PM");return n},d={A:[o,function(t){this.afternoon=h(t,!1)}],a:[o,function(t){this.afternoon=h(t,!0)}],S:[/\d/,function(t){this.milliseconds=100*+t}],SS:[r,function(t){this.milliseconds=10*+t}],SSS:[/\d{3}/,function(t){this.milliseconds=+t}],s:[i,a("seconds")],ss:[i,a("seconds")],m:[i,a("minutes")],mm:[i,a("minutes")],H:[i,a("hours")],h:[i,a("hours")],HH:[i,a("hours")],hh:[i,a("hours")],D:[i,a("day")],DD:[r,a("day")],Do:[o,function(t){var e=s.ordinal,n=t.match(/\d+/);if(this.day=n[0],e)for(var r=1;r<=31;r+=1)e(r).replace(/\[|\]/g,"")===t&&(this.day=r)}],M:[i,a("month")],MM:[r,a("month")],MMM:[o,function(t){var e=u("months"),n=(u("monthsShort")||e.map(function(t){return t.substr(0,3)})).indexOf(t)+1;if(n<1)throw new Error;this.month=n%12||n}],MMMM:[o,function(t){var e=u("months").indexOf(t)+1;if(e<1)throw new Error;this.month=e%12||e}],Y:[/[+-]?\d+/,a("year")],YY:[r,function(t){t=+t,this.year=t+(t>68?1900:2e3)}],YYYY:[/\d{4}/,a("year")],Z:f,ZZ:f};var c=function(t,r,i){try{var o=function(t){for(var r=(t=e(t,s&&s.formats)).match(n),i=r.length,o=0;o<i;o+=1){var a=r[o],f=d[a],u=f&&f[0],h=f&&f[1];r[o]=h?{regex:u,parser:h}:a.replace(/^\[|\]$/g,"")}return function(t){for(var e={},n=0,o=0;n<i;n+=1){var s=r[n];if("string"==typeof s)o+=s.length;else{var a=s.regex,f=s.parser,u=t.substr(o),h=a.exec(u)[0];f.call(e,h),t=t.replace(h,"")}}return function(t){var e=t.afternoon;if(void 0!==e){var n=t.hours;e?n<12&&(t.hours+=12):12===n&&(t.hours=0),delete t.afternoon}}(e),e}}(r)(t),a=o.year,f=o.month,u=o.day,h=o.hours,c=o.minutes,m=o.seconds,l=o.milliseconds,M=o.zone,Y=new Date,v=u||(a||f?1:Y.getDate()),p=a||Y.getFullYear(),D=0;a&&!f||(D=f>0?f-1:Y.getMonth());var y=h||0,L=c||0,g=m||0,$=l||0;return M?new Date(Date.UTC(p,D,v,y,L,g,$+60*M.offset*1e3)):i?new Date(Date.UTC(p,D,v,y,L,g,$)):new Date(p,D,v,y,L,g,$)}catch(t){return new Date("")}};return function(t,e,n){n.p.customParseFormat=!0;var r=e.prototype,i=r.parse;r.parse=function(t){var e=t.date,r=t.utc,o=t.args;this.$u=r;var a=o[1];if("string"==typeof a){var f=!0===o[2],u=!0===o[3],h=f||u,d=o[2];u&&(d=o[2]),s=this.$locale(),!f&&d&&(s=n.Ls[d]),this.$d=c(e,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),h&&e!==this.format(a)&&(this.$d=new Date("")),s={}}else if(a instanceof Array)for(var m=a.length,l=1;l<=m;l+=1){o[1]=a[l-1];var M=n.apply(this,o);if(M.isValid()){this.$d=M.$d,this.$L=M.$L,this.init();break}l===m&&(this.$d=new Date(""))}else i.call(this,t)}}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.dayjs_plugin_customParseFormat=e()}(this,function(){"use strict";var t={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},e=function(e,n){return e.replace(/(\[[^\]]+])|(LTS?|l{1,4}|L{1,4})/g,function(e,r,i){var o=i&&i.toUpperCase();return r||n[i]||t[i]||n[o].replace(/(\[[^\]]+])|(MMMM|MM|DD|dddd)/g,function(t,e,n){return e||n.slice(1)})})},n=/(\[[^[]*\])|([-:/.()\s]+)|(A|a|YYYY|YY?|MM?M?M?|Do|DD?|hh?|HH?|mm?|ss?|S{1,3}|z|ZZ?)/g,r=/\d\d/,i=/\d\d?/,o=/\d*[^\s\d-_:/()]+/,s={};var a=function(t){return function(e){this[t]=+e}},f=[/[+-]\d\d:?(\d\d)?/,function(t){(this.zone||(this.zone={})).offset=function(t){if(!t)return 0;var e=t.match(/([+-]|\d\d)/g),n=60*e[1]+(+e[2]||0);return 0===n?0:"+"===e[0]?-n:n}(t)}],u=function(t){var e=s[t];return e&&(e.indexOf?e:e.s.concat(e.f))},h=function(t,e){var n,r=s.meridiem;if(r){for(var i=1;i<=24;i+=1)if(t.indexOf(r(i,0,e))>-1){n=i>12;break}}else n=t===(e?"pm":"PM");return n},d={A:[o,function(t){this.afternoon=h(t,!1)}],a:[o,function(t){this.afternoon=h(t,!0)}],S:[/\d/,function(t){this.milliseconds=100*+t}],SS:[r,function(t){this.milliseconds=10*+t}],SSS:[/\d{3}/,function(t){this.milliseconds=+t}],s:[i,a("seconds")],ss:[i,a("seconds")],m:[i,a("minutes")],mm:[i,a("minutes")],H:[i,a("hours")],h:[i,a("hours")],HH:[i,a("hours")],hh:[i,a("hours")],D:[i,a("day")],DD:[r,a("day")],Do:[o,function(t){var e=s.ordinal,n=t.match(/\d+/);if(this.day=n[0],e)for(var r=1;r<=31;r+=1)e(r).replace(/\[|\]/g,"")===t&&(this.day=r)}],M:[i,a("month")],MM:[r,a("month")],MMM:[o,function(t){var e=u("months"),n=(u("monthsShort")||e.map(function(t){return t.substr(0,3)})).indexOf(t)+1;if(n<1)throw new Error;this.month=n%12||n}],MMMM:[o,function(t){var e=u("months").indexOf(t)+1;if(e<1)throw new Error;this.month=e%12||e}],Y:[/[+-]?\d+/,a("year")],YY:[r,function(t){t=+t,this.year=t+(t>68?1900:2e3)}],YYYY:[/\d{4}/,a("year")],Z:f,ZZ:f};var c=function(t,r,i){try{var o=function(t){for(var r=(t=e(t,s&&s.formats)).match(n),i=r.length,o=0;o<i;o+=1){var a=r[o],f=d[a],u=f&&f[0],h=f&&f[1];r[o]=h?{regex:u,parser:h}:a.replace(/^\[|\]$/g,"")}return function(t){for(var e={},n=0,o=0;n<i;n+=1){var s=r[n];if("string"==typeof s)o+=s.length;else{var a=s.regex,f=s.parser,u=t.substr(o),h=a.exec(u)[0];f.call(e,h),t=t.replace(h,"")}}return function(t){var e=t.afternoon;if(void 0!==e){var n=t.hours;e?n<12&&(t.hours+=12):12===n&&(t.hours=0),delete t.afternoon}}(e),e}}(r)(t),a=o.year,f=o.month,u=o.day,h=o.hours,c=o.minutes,m=o.seconds,l=o.milliseconds,M=o.zone,Y=new Date,v=u||(a||f?1:Y.getDate()),p=a||Y.getFullYear(),D=0;a&&!f||(D=f>0?f-1:Y.getMonth());var y=h||0,L=c||0,g=m||0,$=l||0;return M?new Date(Date.UTC(p,D,v,y,L,g,$+60*M.offset*1e3)):i?new Date(Date.UTC(p,D,v,y,L,g,$)):new Date(p,D,v,y,L,g,$)}catch(t){return new Date("")}};return function(t,e,n){n.p.customParseFormat=!0;var r=e.prototype,i=r.parse;r.parse=function(t){var e=t.date,r=t.utc,o=t.args;this.$u=r;var a=o[1];if("string"==typeof a){var f=!0===o[2],u=!0===o[3],h=f||u,d=o[2];u&&(d=o[2]),s=this.$locale(),!f&&d&&(s=n.Ls[d]),this.$d=c(e,a,r),this.init(),d&&!0!==d&&(this.$L=this.locale(d).$L),h&&e!==this.format(a)&&(this.$d=new Date("")),s={}}else if(a instanceof Array)for(var m=a.length,l=1;l<=m;l+=1){o[1]=a[l-1];var M=n.apply(this,o);if(M.isValid()){this.$d=M.$d,this.$L=M.$L,this.init();break}l===m&&(this.$d=new Date(""))}else i.call(this,t)}}}); |
import { PluginFunc } from 'dayjs' | ||
import { OpUnitType, UnitTypeLongPlural } from "../index"; | ||
@@ -8,7 +9,13 @@ declare const plugin: PluginFunc | ||
declare namespace plugin { | ||
type DurationInputType = string | number | object | ||
type DurationAddType = number | object | Duration | ||
type DurationUnitsObjectType = Partial<{ | ||
[unit in Exclude<UnitTypeLongPlural, "dates"> | "weeks"]: number | ||
}>; | ||
type DurationUnitType = Exclude<OpUnitType, "date" | "dates"> | ||
type CreateDurationType = | ||
((units: DurationUnitsObjectType) => Duration) | ||
& ((time: number, unit?: DurationUnitType) => Duration) | ||
& ((ISO_8601: string) => Duration) | ||
interface Duration { | ||
new (input: DurationInputType, unit?: string, locale?: string): Duration | ||
new (input: string | number | object, unit?: string, locale?: string): Duration | ||
@@ -43,10 +50,10 @@ clone(): Duration | ||
as(unit: string): number | ||
as(unit: DurationUnitType): number | ||
get(unit: string): number | ||
get(unit: DurationUnitType): number | ||
add(input: DurationAddType, unit? : string): Duration | ||
add: CreateDurationType; | ||
subtract: CreateDurationType | ||
subtract(input: DurationAddType, unit? : string): Duration | ||
toJSON(): string | ||
@@ -64,8 +71,11 @@ | ||
interface Dayjs { | ||
add(value: plugin.Duration): Dayjs | ||
subtract(value: plugin.Duration): Dayjs | ||
add(duration: plugin.Duration): Dayjs | ||
subtract(duration: plugin.Duration): Dayjs | ||
} | ||
export function duration(input?: plugin.DurationInputType , unit?: string): plugin.Duration | ||
/** | ||
* @param time If unit is not present, time treated as number of milliseconds | ||
*/ | ||
export const duration: plugin.CreateDurationType; | ||
export function isDuration(d: any): d is plugin.Duration | ||
} |
@@ -1,1 +0,1 @@ | ||
!function(s,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):s.dayjs_plugin_duration=t()}(this,function(){"use strict";var s,t,i=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,n=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,e={years:31536e6,months:2592e6,days:864e5,hours:36e5,minutes:6e4,seconds:1e3,milliseconds:1,weeks:6048e5},r=function(s){return s instanceof u},o=function(s,t,i){return new u(s,i,t.$l)},h=function(s){return t.p(s)+"s"},u=function(){function u(s,t,i){var r=this;if(this.$d={},this.$l=i,t)return o(s*e[h(t)],this);if("number"==typeof s)return this.$ms=s,this.parseFromMilliseconds(),this;if("object"==typeof s)return Object.keys(s).forEach(function(t){r.$d[h(t)]=s[t]}),this.calMilliseconds(),this;if("string"==typeof s){var u=s.match(n);if(u)return this.$d.years=u[2],this.$d.months=u[3],this.$d.weeks=u[4],this.$d.days=u[5],this.$d.hours=u[6],this.$d.minutes=u[7],this.$d.seconds=u[8],this.calMilliseconds(),this}return this}var d=u.prototype;return d.calMilliseconds=function(){var s=this;this.$ms=Object.keys(this.$d).reduce(function(t,i){return t+(s.$d[i]||0)*e[i]},0)},d.parseFromMilliseconds=function(){var s=this.$ms;this.$d.years=Math.floor(s/31536e6),s%=31536e6,this.$d.months=Math.floor(s/2592e6),s%=2592e6,this.$d.days=Math.floor(s/864e5),s%=864e5,this.$d.hours=Math.floor(s/36e5),s%=36e5,this.$d.minutes=Math.floor(s/6e4),s%=6e4,this.$d.seconds=Math.floor(s/1e3),s%=1e3,this.$d.milliseconds=s},d.toISOString=function(){var s=this.$d.years?this.$d.years+"Y":"",t=this.$d.months?this.$d.months+"M":"",i=+this.$d.days||0;this.$d.weeks&&(i+=7*this.$d.weeks);var n=i?i+"D":"",e=this.$d.hours?this.$d.hours+"H":"",r=this.$d.minutes?this.$d.minutes+"M":"",o=this.$d.seconds||0;this.$d.milliseconds&&(o+=this.$d.milliseconds/1e3);var h=o?o+"S":"",u="P"+s+t+n+(e||r||h?"T":"")+e+r+h;return"P"===u?"P0D":u},d.toJSON=function(){return this.toISOString()},d.format=function(s){var n=s||"YYYY-MM-DDTHH:mm:ss",e={Y:this.$d.years,YY:t.s(this.$d.years,2,"0"),YYYY:t.s(this.$d.years,4,"0"),M:this.$d.months,MM:t.s(this.$d.months,2,"0"),D:this.$d.days,DD:t.s(this.$d.days,2,"0"),H:this.$d.hours,HH:t.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:t.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:t.s(this.$d.seconds,2,"0"),SSS:t.s(this.$d.milliseconds,3,"0")};return n.replace(i,function(s,t){return t||String(e[s])})},d.as=function(s){return this.$ms/e[h(s)]},d.get=function(s){var t=this.$ms,i=h(s);return"milliseconds"===i?t%=1e3:t="weeks"===i?Math.floor(t/e[i]):this.$d[i],t},d.add=function(s,t,i){var n;return n=t?s*e[h(t)]:r(s)?s.$ms:o(s,this).$ms,o(this.$ms+n*(i?-1:1),this)},d.subtract=function(s,t){return this.add(s,t,!0)},d.locale=function(s){var t=this.clone();return t.$l=s,t},d.clone=function(){return o(this.$ms,this)},d.humanize=function(t){return s().add(this.$ms,"ms").locale(this.$l).fromNow(!t)},d.milliseconds=function(){return this.get("milliseconds")},d.asMilliseconds=function(){return this.as("milliseconds")},d.seconds=function(){return this.get("seconds")},d.asSeconds=function(){return this.as("seconds")},d.minutes=function(){return this.get("minutes")},d.asMinutes=function(){return this.as("minutes")},d.hours=function(){return this.get("hours")},d.asHours=function(){return this.as("hours")},d.days=function(){return this.get("days")},d.asDays=function(){return this.as("days")},d.weeks=function(){return this.get("weeks")},d.asWeeks=function(){return this.as("weeks")},d.months=function(){return this.get("months")},d.asMonths=function(){return this.as("months")},d.years=function(){return this.get("years")},d.asYears=function(){return this.as("years")},u}();return function(i,n,e){s=e,t=e().$utils(),e.duration=function(s,t){var i=e.locale();return o(s,{$l:i},t)},e.isDuration=r;var h=n.prototype.add,u=n.prototype.subtract;n.prototype.add=function(s,t){return r(s)&&(s=s.asMilliseconds()),h.bind(this)(s,t)},n.prototype.subtract=function(s,t){return r(s)&&(s=s.asMilliseconds()),u.bind(this)(s,t)}}}); | ||
!function(t,s){"object"==typeof exports&&"undefined"!=typeof module?module.exports=s():"function"==typeof define&&define.amd?define(s):t.dayjs_plugin_duration=s()}(this,function(){"use strict";var t,s,n=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,i=/^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/,e={years:31536e6,months:2592e6,days:864e5,hours:36e5,minutes:6e4,seconds:1e3,milliseconds:1,weeks:6048e5},r=function(t){return t instanceof c},o=function(t,s,n){return new c(t,n,s.$l)},u=function(t){return s.p(t)+"s"},h=function(t){return t<0},a=function(t){return h(t)?Math.ceil(t):Math.floor(t)},d=function(t,s){return t?h(t)?{negative:!0,format:""+function(t){return Math.abs(t)}(t)+s}:{negative:!1,format:""+t+s}:{negative:!1,format:""}},c=function(){function h(t,s,n){var r=this;if(this.$d={},this.$l=n,s)return o(t*e[u(s)],this);if("number"==typeof t)return this.$ms=t,this.parseFromMilliseconds(),this;if("object"==typeof t)return Object.keys(t).forEach(function(s){r.$d[u(s)]=t[s]}),this.calMilliseconds(),this;if("string"==typeof t){var h=t.match(i);if(h)return this.$d.years=h[2],this.$d.months=h[3],this.$d.weeks=h[4],this.$d.days=h[5],this.$d.hours=h[6],this.$d.minutes=h[7],this.$d.seconds=h[8],this.calMilliseconds(),this}return this}var c=h.prototype;return c.calMilliseconds=function(){var t=this;this.$ms=Object.keys(this.$d).reduce(function(s,n){return s+(t.$d[n]||0)*e[n]},0)},c.parseFromMilliseconds=function(){var t=this.$ms;this.$d.years=a(t/31536e6),t%=31536e6,this.$d.months=a(t/2592e6),t%=2592e6,this.$d.days=a(t/864e5),t%=864e5,this.$d.hours=a(t/36e5),t%=36e5,this.$d.minutes=a(t/6e4),t%=6e4,this.$d.seconds=a(t/1e3),t%=1e3,this.$d.milliseconds=t},c.toISOString=function(){var t=d(this.$d.years,"Y"),s=d(this.$d.months,"M"),n=+this.$d.days||0;this.$d.weeks&&(n+=7*this.$d.weeks);var i=d(n,"D"),e=d(this.$d.hours,"H"),r=d(this.$d.minutes,"M"),o=this.$d.seconds||0;this.$d.milliseconds&&(o+=this.$d.milliseconds/1e3);var u=d(o,"S"),h=t.negative||s.negative||i.negative||e.negative||r.negative||u.negative,a=e.format||r.format||u.format?"T":"",c=(h?"-":"")+"P"+t.format+s.format+i.format+a+e.format+r.format+u.format;return"P"===c||"-P"===c?"P0D":c},c.toJSON=function(){return this.toISOString()},c.format=function(t){var i=t||"YYYY-MM-DDTHH:mm:ss",e={Y:this.$d.years,YY:s.s(this.$d.years,2,"0"),YYYY:s.s(this.$d.years,4,"0"),M:this.$d.months,MM:s.s(this.$d.months,2,"0"),D:this.$d.days,DD:s.s(this.$d.days,2,"0"),H:this.$d.hours,HH:s.s(this.$d.hours,2,"0"),m:this.$d.minutes,mm:s.s(this.$d.minutes,2,"0"),s:this.$d.seconds,ss:s.s(this.$d.seconds,2,"0"),SSS:s.s(this.$d.milliseconds,3,"0")};return i.replace(n,function(t,s){return s||String(e[t])})},c.as=function(t){return this.$ms/e[u(t)]},c.get=function(t){var s=this.$ms,n=u(t);return"milliseconds"===n?s%=1e3:s="weeks"===n?a(s/e[n]):this.$d[n],0===s?0:s},c.add=function(t,s,n){var i;return i=s?t*e[u(s)]:r(t)?t.$ms:o(t,this).$ms,o(this.$ms+i*(n?-1:1),this)},c.subtract=function(t,s){return this.add(t,s,!0)},c.locale=function(t){var s=this.clone();return s.$l=t,s},c.clone=function(){return o(this.$ms,this)},c.humanize=function(s){return t().add(this.$ms,"ms").locale(this.$l).fromNow(!s)},c.milliseconds=function(){return this.get("milliseconds")},c.asMilliseconds=function(){return this.as("milliseconds")},c.seconds=function(){return this.get("seconds")},c.asSeconds=function(){return this.as("seconds")},c.minutes=function(){return this.get("minutes")},c.asMinutes=function(){return this.as("minutes")},c.hours=function(){return this.get("hours")},c.asHours=function(){return this.as("hours")},c.days=function(){return this.get("days")},c.asDays=function(){return this.as("days")},c.weeks=function(){return this.get("weeks")},c.asWeeks=function(){return this.as("weeks")},c.months=function(){return this.get("months")},c.asMonths=function(){return this.as("months")},c.years=function(){return this.get("years")},c.asYears=function(){return this.as("years")},h}();return function(n,i,e){t=e,s=e().$utils(),e.duration=function(t,s){var n=e.locale();return o(t,{$l:n},s)},e.isDuration=r;var u=i.prototype.add,h=i.prototype.subtract;i.prototype.add=function(t,s){return r(t)&&(t=t.asMilliseconds()),u.bind(this)(t,s)},i.prototype.subtract=function(t,s){return r(t)&&(t=t.asMilliseconds()),h.bind(this)(t,s)}}}); |
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
587272
10202