Socket
Socket
Sign inDemoInstall

@drivekyte/date-utils

Package Overview
Dependencies
5
Maintainers
6
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.3.0 to 2.4.0

10

dist/date-utils.es5.js

@@ -869,5 +869,7 @@ 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 add = (date, value, unit) => dayjs(date).add(value, unit);
const subtract = (date, value, unit) => dayjs(date).subtract(value, unit);
const set = (date, unit, value) => dayjs(date).set(unit, value);
const getStartOf = (date, unit) => dayjs(date).startOf(unit).toDate();
const getEndOf = (date, unit) => dayjs(date).endOf(unit).toDate();
const useDateTransformer = () => ({

@@ -881,2 +883,4 @@ getDateInServiceAreaTz,

set,
getStartOf,
getEndOf,
});

@@ -883,0 +887,0 @@

@@ -873,5 +873,7 @@ '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 add = (date, value, unit) => dayjs(date).add(value, unit);
const subtract = (date, value, unit) => dayjs(date).subtract(value, unit);
const set = (date, unit, value) => dayjs(date).set(unit, value);
const getStartOf = (date, unit) => dayjs(date).startOf(unit).toDate();
const getEndOf = (date, unit) => dayjs(date).endOf(unit).toDate();
const useDateTransformer = () => ({

@@ -885,2 +887,4 @@ getDateInServiceAreaTz,

set,
getStartOf,
getEndOf,
});

@@ -887,0 +891,0 @@

@@ -34,5 +34,7 @@ "use strict";

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 add = (date, value, unit) => (0, dayjs_1.default)(date).add(value, unit);
const subtract = (date, value, unit) => (0, dayjs_1.default)(date).subtract(value, unit);
const set = (date, unit, value) => (0, dayjs_1.default)(date).set(unit, value);
const getStartOf = (date, unit) => (0, dayjs_1.default)(date).startOf(unit).toDate();
const getEndOf = (date, unit) => (0, dayjs_1.default)(date).endOf(unit).toDate();
const useDateTransformer = () => ({

@@ -46,4 +48,6 @@ getDateInServiceAreaTz,

set,
getStartOf,
getEndOf,
});
exports.default = useDateTransformer;
//# sourceMappingURL=use-date-transformer.js.map

@@ -53,5 +53,3 @@ "use strict";

const originalDate = new Date(2022, 8, 30, 10, 20);
expect(result.current
.add(originalDate, { value: 10, unit: 'minutes' })
.get('minutes')).toEqual(30);
expect(result.current.add(originalDate, 10, 'minutes').get('minutes')).toEqual(30);
});

@@ -63,5 +61,3 @@ });

const originalDate = new Date(2022, 8, 30, 10, 20);
expect(result.current
.subtract(originalDate, { value: 10, unit: 'minutes' })
.get('minutes')).toEqual(10);
expect(result.current.subtract(originalDate, 10, 'minutes').get('minutes')).toEqual(10);
});

@@ -73,8 +69,20 @@ });

const originalDate = new Date(2022, 8, 10, 10, 20);
expect(result.current
.set(originalDate, { value: 5, unit: 'days' })
.get('days')).toEqual(5);
expect(result.current.set(originalDate, 'days', 5).get('days')).toEqual(5);
});
});
describe('getStartOf', () => {
it('should return the startOf the day', () => {
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.getStartOf(originalDate, 'date').getHours()).toEqual(0);
});
});
describe('getEndOf', () => {
it('should return the endOf the day', () => {
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.getEndOf(originalDate, 'date').getHours()).toEqual(23);
});
});
});
//# sourceMappingURL=use-date-transformer.test.js.map

@@ -8,15 +8,8 @@ import dayjs from 'dayjs';

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;
add: (date: string | number | Date, value: number, unit?: dayjs.ManipulateType | undefined) => dayjs.Dayjs;
subtract: (date: string | number | Date, value: number, unit?: dayjs.ManipulateType | undefined) => dayjs.Dayjs;
set: (date: string | number | Date, unit: dayjs.UnitType, value: number) => dayjs.Dayjs;
getStartOf: (date: string | number | Date | dayjs.Dayjs, unit: dayjs.OpUnitType) => Date;
getEndOf: (date: string | number | Date | dayjs.Dayjs, unit: dayjs.OpUnitType) => Date;
};
export default useDateTransformer;
{
"name": "@drivekyte/date-utils",
"version": "2.3.0",
"version": "2.4.0",
"description": "",

@@ -5,0 +5,0 @@ "keywords": [],

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc