Socket
Socket
Sign inDemoInstall

@talend/utils

Package Overview
Dependencies
2
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.9.0 to 3.0.0

6

CHANGELOG.md
# @talend/utils
## 3.0.0
### Major Changes
- 922e3eb: deps: bump date-fns to 3.X
## 2.9.0

@@ -4,0 +10,0 @@

3

lib/date/generator.d.ts

@@ -0,4 +1,5 @@

import { Day } from 'date-fns/types';
/**
* Generate the set of weeks for a specific month
*/
export declare function buildWeeks(year: number, monthIndex: number, firstDayOfWeek?: number): Date[][];
export declare function buildWeeks(year: number, monthIndex: number, firstDayOfWeek?: Day): Date[][];

@@ -7,18 +7,16 @@ "use strict";

exports.buildWeeks = buildWeeks;
var _addDays = _interopRequireDefault(require("date-fns/addDays"));
var _startOfWeek = _interopRequireDefault(require("date-fns/startOfWeek"));
var _addDays = require("date-fns/addDays");
var _startOfWeek = require("date-fns/startOfWeek");
var _lodash = require("lodash");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**
* Generate the set of weeks for a specific month
*/
function buildWeeks(year, monthIndex) {
let firstDayOfWeek = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 1;
function buildWeeks(year, monthIndex, firstDayOfWeek = 1) {
const firstDateOfMonth = new Date(year, monthIndex);
const firstDateOfCalendar = (0, _startOfWeek.default)(firstDateOfMonth, {
const firstDateOfCalendar = (0, _startOfWeek.startOfWeek)(firstDateOfMonth, {
weekStartsOn: firstDayOfWeek
});
const dates = new Array(7 * 6).fill(0).map((_, i) => (0, _addDays.default)(firstDateOfCalendar, i));
const dates = new Array(7 * 6).fill(0).map((_, i) => (0, _addDays.addDays)(firstDateOfCalendar, i));
return (0, _lodash.chunk)(dates, 7);
}
//# sourceMappingURL=generator.js.map

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

import { FormatOptions } from 'date-fns/format';
import * as generator from './generator';

@@ -55,3 +56,3 @@ type DateFnsFormatInput = Date | number | string;

*/
export declare function formatToTimeZone(date: DateFnsFormatInput, formatString: string, options: ConversionOptions): string;
export declare function formatToTimeZone(date: DateFnsFormatInput, formatString: string, options: FormatOptions & ConversionOptions): string;
/**

@@ -58,0 +59,0 @@ * Convert a date in local TZ to UTC

@@ -17,8 +17,7 @@ "use strict";

exports.timeZoneExists = timeZoneExists;
var _format = _interopRequireDefault(require("date-fns/format"));
var _parseISO = _interopRequireDefault(require("date-fns/parseISO"));
var _format = require("date-fns/format");
var _parseISO = require("date-fns/parseISO");
var generator = _interopRequireWildcard(require("./generator"));
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
/**

@@ -112,3 +111,3 @@ * Get the offset between a timezone and the UTC time (in minutes)

function convertToLocalTime(date, options) {
const parsedDate = (0, _parseISO.default)(new Date(date).toISOString());
const parsedDate = (0, _parseISO.parseISO)(new Date(date).toISOString());
const offset = getUTCOffset(options.timeZone) + parsedDate.getTimezoneOffset();

@@ -132,3 +131,3 @@ return new Date(parsedDate.getTime() - offset * 60 * 1000);

} = options;
const parsedDate = (0, _parseISO.default)(new Date(date).toISOString());
const parsedDate = (0, _parseISO.parseISO)(new Date(date).toISOString());
let offset = getUTCOffset(timeZone, parsedDate) + parsedDate.getTimezoneOffset();

@@ -172,3 +171,3 @@ if (sourceTimeZone) {

.replace(/\[Z\]/g, () => "'Z'");
return (0, _format.default)(dateConvertedToTimezone, dateFnsFormatWithTimeZoneValue, options);
return (0, _format.format)(dateConvertedToTimezone, dateFnsFormatWithTimeZoneValue, options);
}

@@ -252,3 +251,3 @@

function format(date, dateOption, lang) {
const parsedDate = (0, _parseISO.default)(new Date(date).toISOString());
const parsedDate = (0, _parseISO.parseISO)(new Date(date).toISOString());
return new Intl.DateTimeFormat(lang, options[dateOption]).format(parsedDate);

@@ -255,0 +254,0 @@ }

{
"name": "@talend/utils",
"version": "2.9.0",
"version": "3.0.0",
"description": "Various utilities",

@@ -34,3 +34,3 @@ "main": "lib/index.js",

"dependencies": {
"date-fns": "^2.30.0",
"date-fns": "^3.0.0",
"lodash": "^4.17.21"

@@ -37,0 +37,0 @@ },

@@ -1,3 +0,3 @@

import dateFnsFormat from 'date-fns/format';
import enGB from 'date-fns/locale/en-GB';
import { format as dateFnsFormat } from 'date-fns/format';
import { enGB } from 'date-fns/locale/en-GB';

@@ -20,3 +20,4 @@ import {

__esModule: true,
default: jest.fn().mockImplementation(actualFormat),
default: jest.fn().mockImplementation(actualFormat.default),
format: jest.fn().mockImplementation(actualFormat.format),
};

@@ -141,2 +142,3 @@ });

});
it('should pass locale to datefns format method', () => {

@@ -143,0 +145,0 @@ // given

@@ -1,3 +0,4 @@

import addDays from 'date-fns/addDays';
import startOfWeek from 'date-fns/startOfWeek';
import { addDays } from 'date-fns/addDays';
import { startOfWeek } from 'date-fns/startOfWeek';
import { Day } from 'date-fns/types';
import chunk from 'lodash/chunk';

@@ -8,3 +9,3 @@

*/
export function buildWeeks(year: number, monthIndex: number, firstDayOfWeek = 1) {
export function buildWeeks(year: number, monthIndex: number, firstDayOfWeek: Day = 1) {
const firstDateOfMonth = new Date(year, monthIndex);

@@ -11,0 +12,0 @@ const firstDateOfCalendar = startOfWeek(firstDateOfMonth, {

@@ -1,3 +0,3 @@

import dateFnsFormat from 'date-fns/format';
import parseISO from 'date-fns/parseISO';
import { format as dateFnsFormat, FormatOptions } from 'date-fns/format';
import { parseISO } from 'date-fns/parseISO';

@@ -162,3 +162,3 @@ import * as generator from './generator';

formatString: string,
options: ConversionOptions,
options: FormatOptions & ConversionOptions,
): string {

@@ -165,0 +165,0 @@ const dateConvertedToTimezone = convertToTimeZone(date, options);

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