@abip/sp-common
Advanced tools
Comparing version 0.1.27 to 0.1.29
@@ -12,3 +12,4 @@ export declare function parseDateToDateTime(date: string | number): string; | ||
export declare function getTimeOfDateTime(dateTime: string, options?: TimeOfDateTimeOptions): string; | ||
export declare function buildDateTimeFromDateAndTime(date: Date | string, time: string): string; | ||
export {}; | ||
//# sourceMappingURL=date.d.ts.map |
@@ -9,3 +9,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getTimeOfDateTime = exports.removeSecondsFromTime = exports.getDateOfDateTime = exports.parseDateToDateTime = void 0; | ||
exports.buildDateTimeFromDateAndTime = exports.getTimeOfDateTime = exports.removeSecondsFromTime = exports.getDateOfDateTime = exports.parseDateToDateTime = void 0; | ||
const date_fns_1 = require("date-fns"); | ||
function parseDateToDateTime(date) { | ||
@@ -47,2 +48,23 @@ return new Date(date) | ||
exports.getTimeOfDateTime = getTimeOfDateTime; | ||
function buildDateTimeFromDateAndTime(date, time) { | ||
let instance; | ||
if (date) { | ||
instance = new Date(`${date}`); | ||
} | ||
else { | ||
instance = new Date(); | ||
} | ||
if (time) { | ||
const [hours, minutes] = time.split(':'); | ||
instance = (0, date_fns_1.add)(instance, { | ||
hours: parseInt(hours, 10), | ||
minutes: parseInt(minutes, 10), | ||
}); | ||
} | ||
return instance | ||
.toISOString() | ||
.slice(0, 19) | ||
.replace('T', ' '); | ||
} | ||
exports.buildDateTimeFromDateAndTime = buildDateTimeFromDateAndTime; | ||
//# sourceMappingURL=date.js.map |
{ | ||
"name": "@abip/sp-common", | ||
"version": "0.1.27", | ||
"version": "0.1.29", | ||
"description": "", | ||
@@ -33,2 +33,3 @@ "main": "./dist/index", | ||
"dependencies": { | ||
"date-fns": "^2.28.0", | ||
"lodash.template": "^4.5.0", | ||
@@ -45,3 +46,3 @@ "nanoid": "^3.3.4" | ||
}, | ||
"gitHead": "5876fd0d00876aae9efa652d96953d61b4394507" | ||
"gitHead": "3aa7845cf41e1fd07ca5280a868ba8d5223a8b67" | ||
} |
@@ -8,2 +8,4 @@ /* | ||
import { add } from 'date-fns'; | ||
export function parseDateToDateTime(date: string | number) { | ||
@@ -63,1 +65,25 @@ return new Date(date) | ||
} | ||
export function buildDateTimeFromDateAndTime(date: Date | string, time: string) { | ||
let instance : Date; | ||
if (date) { | ||
instance = new Date(`${date}`); | ||
} else { | ||
instance = new Date(); | ||
} | ||
if (time) { | ||
const [hours, minutes] = time.split(':'); | ||
instance = add(instance, { | ||
hours: parseInt(hours, 10), | ||
minutes: parseInt(minutes, 10), | ||
}); | ||
} | ||
return instance | ||
.toISOString() | ||
.slice(0, 19) | ||
.replace('T', ' '); | ||
} |
Sorry, the diff of this file is not supported yet
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
281482
4894
6
+ Addeddate-fns@^2.28.0
+ Addeddate-fns@2.30.0(transitive)