You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

@drivekyte/date-utils

Package Overview
Dependencies
Maintainers
6
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@drivekyte/date-utils - npm Package Compare versions

Comparing version

to
2.3.0

6

dist/date-utils.es5.js

@@ -869,2 +869,5 @@ var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};

};
const add = (date, options) => dayjs(date).add(options.value, options.unit);
const subtract = (date, options) => dayjs(date).subtract(options.value, options.unit);
const set = (date, options) => dayjs(date).set(options.unit, options.value);
const useDateTransformer = () => ({

@@ -875,2 +878,5 @@ getDateInServiceAreaTz,

sanitizeDate,
add,
subtract,
set,
});

@@ -877,0 +883,0 @@

@@ -873,2 +873,5 @@ 'use strict';

};
const add = (date, options) => dayjs(date).add(options.value, options.unit);
const subtract = (date, options) => dayjs(date).subtract(options.value, options.unit);
const set = (date, options) => dayjs(date).set(options.unit, options.value);
const useDateTransformer = () => ({

@@ -879,2 +882,5 @@ getDateInServiceAreaTz,

sanitizeDate,
add,
subtract,
set,
});

@@ -881,0 +887,0 @@

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.sanitizeDate = void 0;
const date_fns_tz_1 = require("date-fns-tz");
const dayjs_1 = __importDefault(require("dayjs"));
const getDateInServiceAreaTz = (date, timezone) => {

@@ -30,2 +34,5 @@ const localDate = new Date(date).getTime();

exports.sanitizeDate = sanitizeDate;
const add = (date, options) => (0, dayjs_1.default)(date).add(options.value, options.unit);
const subtract = (date, options) => (0, dayjs_1.default)(date).subtract(options.value, options.unit);
const set = (date, options) => (0, dayjs_1.default)(date).set(options.unit, options.value);
const useDateTransformer = () => ({

@@ -36,4 +43,7 @@ getDateInServiceAreaTz,

sanitizeDate: exports.sanitizeDate,
add,
subtract,
set,
});
exports.default = useDateTransformer;
//# sourceMappingURL=use-date-transformer.js.map

@@ -49,3 +49,30 @@ "use strict";

});
describe('add', () => {
it('should add 10min to original date', () => {
const { result } = (0, react_hooks_1.renderHook)(() => (0, use_date_transformer_1.default)());
const originalDate = new Date(2022, 8, 30, 10, 20);
expect(result.current
.add(originalDate, { value: 10, unit: 'minutes' })
.get('minutes')).toEqual(30);
});
});
describe('subtract', () => {
it('should subtract 10min from the original date', () => {
const { result } = (0, react_hooks_1.renderHook)(() => (0, use_date_transformer_1.default)());
const originalDate = new Date(2022, 8, 30, 10, 20);
expect(result.current
.subtract(originalDate, { value: 10, unit: 'minutes' })
.get('minutes')).toEqual(10);
});
});
describe('set', () => {
it('should set the original date', () => {
const { result } = (0, react_hooks_1.renderHook)(() => (0, use_date_transformer_1.default)());
const originalDate = new Date(2022, 8, 10, 10, 20);
expect(result.current
.set(originalDate, { value: 5, unit: 'days' })
.get('days')).toEqual(5);
});
});
});
//# sourceMappingURL=use-date-transformer.test.js.map

@@ -0,1 +1,2 @@

import dayjs from 'dayjs';
export declare const sanitizeDate: (date: string) => Date;

@@ -7,3 +8,15 @@ declare const useDateTransformer: () => {

sanitizeDate: (date: string) => Date;
add: (date: Date, options: {
value: number;
unit?: dayjs.ManipulateType;
}) => dayjs.Dayjs;
subtract: (date: Date, options: {
value: number;
unit?: dayjs.ManipulateType;
}) => dayjs.Dayjs;
set: (date: Date, options: {
value: number;
unit: dayjs.UnitType;
}) => dayjs.Dayjs;
};
export default useDateTransformer;

5

package.json
{
"name": "@drivekyte/date-utils",
"version": "2.2.1",
"version": "2.3.0",
"description": "",

@@ -31,4 +31,2 @@ "keywords": [],

"report-coverage": "cat ./coverage/lcov.info | coveralls",
"semantic-release-prepare": "ts-node tools/semantic-release-prepare",
"semantic-release": "semantic-release",
"test:ci": "jest --ci --bail --coverage --silent",

@@ -70,3 +68,2 @@ "test:coverage": "jest --coverage --silent",

"rollup-plugin-typescript2": "^0.30.0",
"semantic-release": "^17.4.5",
"shelljs": "^0.8.5",

@@ -73,0 +70,0 @@ "ts-jest": "^27.0.5",

dist/date-utils.es5.js.map

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

Sorry, the diff of this file is not supported yet