tscommons-core
Advanced tools
Comparing version 1.30.0 to 1.31.0
@@ -51,2 +51,3 @@ import { TDateRange } from '../types/tdate-range'; | ||
static fillEmptyDays(timestamps: Date[]): Date[]; | ||
static getDateRangeFromDateArray(dates: Readonly<(Readonly<Date>)[]>): TDateRange; | ||
static phpDate(format: string, date?: Date, iso?: boolean): string; | ||
@@ -53,0 +54,0 @@ static getDeltaHours(range: TDateRange, inclusive?: boolean): number; |
@@ -415,2 +415,18 @@ "use strict"; | ||
} | ||
static getDateRangeFromDateArray(dates) { | ||
if (dates.length === 0) | ||
throw new Error('No dates to derive range from'); | ||
const min = new Date(dates[0].getTime()); | ||
const max = new Date(dates[0].getTime()); | ||
for (const date of dates.slice(1)) { | ||
if (date.getTime() < min.getTime()) | ||
min.setTime(date.getTime()); | ||
if (date.getTime() > max.getTime()) | ||
max.setTime(date.getTime()); | ||
} | ||
return { | ||
from: min, | ||
to: max | ||
}; | ||
} | ||
static phpDate(format, date, iso = false) { | ||
@@ -417,0 +433,0 @@ if (!date) |
{ | ||
"name": "tscommons-core", | ||
"version": "1.30.0", | ||
"version": "1.31.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
320545
4107