Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@date-io/dayjs

Package Overview
Dependencies
Maintainers
1
Versions
45
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@date-io/dayjs - npm Package Compare versions

Comparing version 1.3.9 to 1.3.11

3

build/dayjs-utils.d.ts

@@ -11,4 +11,5 @@ import defaultDayjs from "dayjs";

declare type Dayjs = defaultDayjs.Dayjs;
declare type Constructor = (...args: Parameters<typeof defaultDayjs>) => Dayjs;
export default class DayjsUtils implements IUtils<defaultDayjs.Dayjs> {
dayjs: typeof defaultDayjs;
dayjs: Constructor;
locale?: string;

@@ -15,0 +16,0 @@ yearFormat: string;

@@ -7,2 +7,11 @@ import defaultDayjs from 'dayjs';

defaultDayjs.extend(advancedFormat);
var withLocale = function (dayjs, locale) {
return !locale ? dayjs : function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return dayjs.apply(void 0, args).locale(locale);
};
};
var DayjsUtils = /** @class */ (function () {

@@ -18,3 +27,3 @@ function DayjsUtils(_a) {

this.dateFormat = "MMMM Do";
this.dayjs = instance || dayjs || defaultDayjs;
this.dayjs = withLocale(instance || dayjs || defaultDayjs, locale);
this.locale = locale;

@@ -38,6 +47,3 @@ }

DayjsUtils.prototype.isNull = function (date) {
if (date === null) {
return true;
}
return false;
return date === null;
};

@@ -72,4 +78,3 @@ DayjsUtils.prototype.getDiff = function (date, comparing, units, float) {

DayjsUtils.prototype.format = function (date, formatString) {
date.locale(this.locale);
return date.format(formatString);
return this.dayjs(date).format(formatString);
};

@@ -149,5 +154,4 @@ DayjsUtils.prototype.formatNumber = function (numberToFormat) {

var _this = this;
return [0, 1, 2, 3, 4, 5, 6].map(function (dayOfWeek) {
return _this.format(_this.dayjs().set("day", dayOfWeek), "dd");
});
var start = this.dayjs().startOf("week");
return [0, 1, 2, 3, 4, 5, 6].map(function (diff) { return _this.format(start.add(diff, "day"), "dd"); });
};

@@ -161,7 +165,7 @@ DayjsUtils.prototype.isEqual = function (value, comparing) {

DayjsUtils.prototype.getWeekArray = function (date) {
var start = date
var start = this.dayjs(date)
.clone()
.startOf("month")
.startOf("week");
var end = date
var end = this.dayjs(date)
.clone()

@@ -168,0 +172,0 @@ .endOf("month")

@@ -11,2 +11,11 @@ 'use strict';

defaultDayjs.extend(advancedFormat);
var withLocale = function (dayjs, locale) {
return !locale ? dayjs : function () {
var args = [];
for (var _i = 0; _i < arguments.length; _i++) {
args[_i] = arguments[_i];
}
return dayjs.apply(void 0, args).locale(locale);
};
};
var DayjsUtils = /** @class */ (function () {

@@ -22,3 +31,3 @@ function DayjsUtils(_a) {

this.dateFormat = "MMMM Do";
this.dayjs = instance || dayjs || defaultDayjs;
this.dayjs = withLocale(instance || dayjs || defaultDayjs, locale);
this.locale = locale;

@@ -42,6 +51,3 @@ }

DayjsUtils.prototype.isNull = function (date) {
if (date === null) {
return true;
}
return false;
return date === null;
};

@@ -76,4 +82,3 @@ DayjsUtils.prototype.getDiff = function (date, comparing, units, float) {

DayjsUtils.prototype.format = function (date, formatString) {
date.locale(this.locale);
return date.format(formatString);
return this.dayjs(date).format(formatString);
};

@@ -153,5 +158,4 @@ DayjsUtils.prototype.formatNumber = function (numberToFormat) {

var _this = this;
return [0, 1, 2, 3, 4, 5, 6].map(function (dayOfWeek) {
return _this.format(_this.dayjs().set("day", dayOfWeek), "dd");
});
var start = this.dayjs().startOf("week");
return [0, 1, 2, 3, 4, 5, 6].map(function (diff) { return _this.format(start.add(diff, "day"), "dd"); });
};

@@ -165,7 +169,7 @@ DayjsUtils.prototype.isEqual = function (value, comparing) {

DayjsUtils.prototype.getWeekArray = function (date) {
var start = date
var start = this.dayjs(date)
.clone()
.startOf("month")
.startOf("week");
var end = date
var end = this.dayjs(date)
.clone()

@@ -172,0 +176,0 @@ .endOf("month")

{
"name": "@date-io/dayjs",
"version": "1.3.9",
"version": "1.3.11",
"description": "Abstraction over common javascript date management libraries",

@@ -9,11 +9,11 @@ "main": "build/index.js",

"peerDependencies": {
"dayjs": "^1.8.15"
"dayjs": "^1.8.16"
},
"dependencies": {
"@date-io/core": "^1.3.9"
"@date-io/core": "^1.3.11"
},
"devDependencies": {
"dayjs": "^1.8.15",
"rollup": "^1.18.0",
"typescript": "^3.5.3"
"dayjs": "^1.8.16",
"rollup": "^1.20.3",
"typescript": "^3.6.2"
},

@@ -45,3 +45,3 @@ "scripts": {

"license": "MIT",
"gitHead": "612dfa035ca8ab0c9b78de9a186460c0b8693e58"
"gitHead": "5c1e9483f74a62e173ed71eb732f78fe5b19ef95"
}

@@ -18,5 +18,9 @@ import defaultDayjs from "dayjs";

type Dayjs = defaultDayjs.Dayjs;
type Constructor = (...args: Parameters<typeof defaultDayjs>) => Dayjs;
const withLocale = (dayjs: typeof defaultDayjs, locale?: string): Constructor =>
!locale ? dayjs : (...args) => dayjs(...args).locale(locale);
export default class DayjsUtils implements IUtils<defaultDayjs.Dayjs> {
public dayjs: typeof defaultDayjs;
public dayjs: Constructor;

@@ -40,3 +44,3 @@ public locale?: string;

constructor({ locale, instance, dayjs }: Opts = {}) {
this.dayjs = instance || dayjs || defaultDayjs;
this.dayjs = withLocale(instance || dayjs || defaultDayjs, locale);
this.locale = locale;

@@ -66,7 +70,3 @@ }

public isNull(date: Dayjs) {
if (date === null) {
return true;
}
return false;
return date === null;
}

@@ -111,4 +111,3 @@

public format(date: Dayjs, formatString: string) {
date.locale(this.locale);
return date.format(formatString);
return this.dayjs(date).format(formatString);
}

@@ -214,5 +213,4 @@

public getWeekdays() {
return [0, 1, 2, 3, 4, 5, 6].map(dayOfWeek =>
this.format(this.dayjs().set("day", dayOfWeek), "dd")
);
const start = this.dayjs().startOf("week");
return [0, 1, 2, 3, 4, 5, 6].map(diff => this.format(start.add(diff, "day"), "dd"));
}

@@ -229,7 +227,7 @@

public getWeekArray(date: Dayjs) {
const start = date
const start = this.dayjs(date)
.clone()
.startOf("month")
.startOf("week");
const end = date
const end = this.dayjs(date)
.clone()

@@ -236,0 +234,0 @@ .endOf("month")

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc