tscommons-core
Advanced tools
Comparing version 1.25.0 to 1.25.1
@@ -47,3 +47,3 @@ import { TDateRange } from '../types/tdate-range'; | ||
static getPastTime(date: Date, time: Date): Date; | ||
static buildClosestDateFromTime(original: Date, hour: number, minute: number, second?: number, millisecond?: number): Date; | ||
static buildClosestDateFromTime(original: Date, hour: number, minute: number, second?: number, millisecond?: number, magic12Hours?: boolean): Date; | ||
static fillEmptyMinutes(timestamps: Date[]): Date[]; | ||
@@ -50,0 +50,0 @@ static fillEmptyHours(timestamps: Date[]): Date[]; |
@@ -314,3 +314,13 @@ "use strict"; | ||
} | ||
static buildClosestDateFromTime(original, hour, minute, second, millisecond) { | ||
static buildClosestDateFromTime(original, hour, minute, second, millisecond, magic12Hours = false) { | ||
if (magic12Hours && hour < 13) { | ||
const magicHour = (hour + 12) % 24; | ||
const normalResult = CommonsDate.buildClosestDateFromTime(original, hour, minute, second, millisecond); | ||
const magicResult = CommonsDate.buildClosestDateFromTime(original, magicHour, minute, second, millisecond); | ||
const normalDelta = Math.abs(original.getTime() - normalResult.getTime()); | ||
const magicDelta = Math.abs(original.getTime() - magicResult.getTime()); | ||
if (magicDelta < normalDelta) | ||
return magicResult; | ||
return normalResult; | ||
} | ||
const clone = new Date(original.getTime()); | ||
@@ -317,0 +327,0 @@ if (hour !== undefined) |
{ | ||
"name": "tscommons-core", | ||
"version": "1.25.0", | ||
"version": "1.25.1", | ||
"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
253067
3376