update to latest standards
This commit is contained in:
@@ -1,45 +1,56 @@
|
||||
export let units = {
|
||||
years: (timesArg = 1): number => {
|
||||
return timesArg * 3.154e+10
|
||||
return timesArg * 3.154e10;
|
||||
},
|
||||
months: (timesArg = 1): number => {
|
||||
return timesArg * 2.628e+9
|
||||
return timesArg * 2.628e9;
|
||||
},
|
||||
weeks: (timesArg = 1) => {
|
||||
return timesArg * 6.048e+8
|
||||
return timesArg * 6.048e8;
|
||||
},
|
||||
days: (timesArg = 1) => {
|
||||
return timesArg * 8.64e+7
|
||||
return timesArg * 8.64e7;
|
||||
},
|
||||
hours: (timesArg = 1) => {
|
||||
return timesArg * 3.6e+6
|
||||
return timesArg * 3.6e6;
|
||||
},
|
||||
minutes: (timesArg = 1) => {
|
||||
return timesArg * 60000
|
||||
return timesArg * 60000;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
export interface IUnitCombinationArg {
|
||||
years?: number
|
||||
months?: number
|
||||
weeks?: number
|
||||
days?: number
|
||||
hours?: number
|
||||
minutes?: number
|
||||
years?: number;
|
||||
months?: number;
|
||||
weeks?: number;
|
||||
days?: number;
|
||||
hours?: number;
|
||||
minutes?: number;
|
||||
}
|
||||
|
||||
export let getMilliSecondsFromUnits = (combinationArg: IUnitCombinationArg) => {
|
||||
let timeInMilliseconds = 0
|
||||
let addMilliSeconds = (milliSecondsArg) => {
|
||||
timeInMilliseconds = timeInMilliseconds + milliSecondsArg
|
||||
let timeInMilliseconds = 0;
|
||||
let addMilliSeconds = milliSecondsArg => {
|
||||
timeInMilliseconds = timeInMilliseconds + milliSecondsArg;
|
||||
};
|
||||
if (combinationArg.years) {
|
||||
addMilliSeconds(units.years(combinationArg.years));
|
||||
}
|
||||
if (combinationArg.months) {
|
||||
addMilliSeconds(units.months(combinationArg.months));
|
||||
}
|
||||
if (combinationArg.weeks) {
|
||||
addMilliSeconds(units.weeks(combinationArg.weeks));
|
||||
}
|
||||
if (combinationArg.days) {
|
||||
addMilliSeconds(units.days(combinationArg.days));
|
||||
}
|
||||
if (combinationArg.hours) {
|
||||
addMilliSeconds(units.hours(combinationArg.hours));
|
||||
}
|
||||
if (combinationArg.minutes) {
|
||||
addMilliSeconds(units.minutes(combinationArg.minutes));
|
||||
}
|
||||
if (combinationArg.years) { addMilliSeconds(units.years(combinationArg.years)) }
|
||||
if (combinationArg.months) { addMilliSeconds(units.months(combinationArg.months)) }
|
||||
if (combinationArg.weeks) { addMilliSeconds(units.weeks(combinationArg.weeks)) }
|
||||
if (combinationArg.days) { addMilliSeconds(units.days(combinationArg.days)) }
|
||||
if (combinationArg.hours) { addMilliSeconds(units.hours(combinationArg.hours)) }
|
||||
if (combinationArg.minutes) { addMilliSeconds(units.minutes(combinationArg.minutes)) }
|
||||
|
||||
return timeInMilliseconds
|
||||
}
|
||||
|
||||
return timeInMilliseconds;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user