@ukon1990/js-utilities
Advanced tools
Comparing version 1.5.0 to 1.5.1
export declare class DateUtil { | ||
private static getDifference; | ||
/** | ||
@@ -3,0 +4,0 @@ * Returns the difference between two dates in milliseconds |
@@ -0,35 +1,22 @@ | ||
import { TimeSince } from '../models/time-since.model'; | ||
export class DateUtil { | ||
/* | ||
private static getDifference(from: Date | number, to: Date | number) { | ||
/* istanbul ignore next */ | ||
static getDifference(from, to) { | ||
let msSince = DateUtil.getDifferenceInMS(from, to); | ||
const minuteInMS = 60000; | ||
const hourInMS = 3600000; | ||
const dayInMs = hourInMS * 24; | ||
const ms = msSince % 1000; | ||
msSince -= ms; | ||
const seconds = ( msSince / 1000) % minuteInMS; | ||
const seconds = (msSince / 1000) % minuteInMS; | ||
msSince -= ms; | ||
const minutes = (msSince / minuteInMS) % minuteInMS; | ||
msSince -= ms; | ||
const hours = (msSince / minuteInMS) % hourInMS; | ||
msSince -= ms; | ||
const days = (msSince / hourInMS) % dayInMs; | ||
msSince -= ms; | ||
const weeks = (msSince / dayInMs) % dayInMs * 7; | ||
return new TimeSince( | ||
weeks, | ||
days, | ||
hours, | ||
minutes, | ||
seconds, | ||
ms); | ||
return new TimeSince(weeks, days, hours, minutes, seconds, ms); | ||
} | ||
*/ | ||
/** | ||
@@ -36,0 +23,0 @@ * Returns the difference between two dates in milliseconds |
import { DateUtil } from './date.util'; | ||
describe('DateUtil', () => { | ||
/* | ||
describe('getDifference', () => { | ||
it('can get time from a year ago or so', () => { | ||
expect(DateUtil.getDifference( | ||
new Date('May 4 2018 09:24:20'), | ||
new Date('July 4 2018 10:34:35'))) | ||
.toEqual( | ||
new TimeSince( | ||
60, // Weeks | ||
6, | ||
1, | ||
10, | ||
15, | ||
0 | ||
) | ||
); | ||
}); | ||
});*/ | ||
it('getDifferenceInMS', () => { | ||
@@ -4,0 +22,0 @@ expect(DateUtil.getDifferenceInMS(new Date('May 4 2018 09:24:20'), new Date('May 4 2018 09:24:21'))) |
@@ -8,4 +8,4 @@ import { ArrayUtil } from './array.util'; | ||
static isNullOrUndefined(value, value2) { | ||
return (!value && isNaN(value)) || value === null && | ||
(!value && isNaN(value2)) || value2 === null; | ||
return (value === undefined && isNaN(value)) || value === null && | ||
(value2 === undefined && isNaN(value2)) || value2 === null; | ||
} | ||
@@ -12,0 +12,0 @@ /** |
{ | ||
"name": "@ukon1990/js-utilities", | ||
"version": "1.5.0", | ||
"version": "1.5.1", | ||
"description": "A light weight package for object and array manipulation. As well as some utilities for matching text.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
import {DateUtil} from './date.util'; | ||
import {TimeSince} from '../models/time-since.model'; | ||
describe('DateUtil', () => {/* | ||
describe('DateUtil', () => { | ||
/* | ||
describe('getDifference', () => { | ||
@@ -12,3 +13,3 @@ it('can get time from a year ago or so', () => { | ||
new TimeSince( | ||
60, | ||
60, // Weeks | ||
6, | ||
@@ -15,0 +16,0 @@ 1, |
import {TimeSince} from '../models/time-since.model'; | ||
export class DateUtil { | ||
/* | ||
private static getDifference(from: Date | number, to: Date | number) { | ||
/* istanbul ignore next */ | ||
private static getDifference(from: Date | number, to: Date | number): TimeSince { | ||
let msSince = DateUtil.getDifferenceInMS(from, to); | ||
@@ -36,3 +36,2 @@ | ||
} | ||
*/ | ||
@@ -39,0 +38,0 @@ /** |
@@ -9,4 +9,4 @@ import {ArrayUtil} from './array.util'; | ||
public static isNullOrUndefined(value: any, value2?: any): boolean { | ||
return (!value && isNaN(value)) || value === null && | ||
(!value && isNaN(value2)) || value2 === null; | ||
return (value === undefined && isNaN(value)) || value === null && | ||
(value2 === undefined && isNaN(value2)) || value2 === null; | ||
} | ||
@@ -13,0 +13,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
204856
3061