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

@date-io/date-fns

Package Overview
Dependencies
Maintainers
1
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@date-io/date-fns - npm Package Compare versions

Comparing version 1.3.13 to 2.0.0

28

build/date-fns-utils.d.ts

@@ -1,14 +0,8 @@

import SampleLocale from "date-fns/locale/en-US";
import { IUtils } from "@date-io/core/IUtils";
declare type Locale = typeof SampleLocale;
import { IUtils, DateIOFormats } from "@date-io/core/IUtils";
declare type Locale = typeof import("date-fns/locale/en-US").default;
export default class DateFnsUtils implements IUtils<Date> {
locale?: Locale;
yearFormat: string;
yearMonthFormat: string;
dateTime12hFormat: string;
dateTime24hFormat: string;
time12hFormat: string;
time24hFormat: string;
dateFormat: string;
constructor({ locale }?: {
formats: DateIOFormats;
constructor({ locale, formats }?: {
formats?: Partial<DateIOFormats>;
locale?: Locale;

@@ -38,3 +32,4 @@ });

parse(value: string, formatString: string): Date;
format(date: Date, formatString: string): string;
format(date: Date, formatKey: keyof DateIOFormats): string;
formatByString(date: Date, formatString: string): string;
isEqual(date: any, comparing: any): boolean;

@@ -58,12 +53,3 @@ isNull(date: Date): boolean;

getYearRange(start: Date, end: Date): Date[];
getCalendarHeaderText(date: Date): string;
getYearText(date: Date): string;
getDatePickerHeaderText(date: Date): string;
getDateTimePickerHeaderText(date: Date): string;
getMonthText(date: Date): string;
getDayText(date: Date): string;
getHourText(date: Date, ampm: boolean): string;
getMinuteText(date: Date): string;
getSecondText(date: Date): string;
}
export {};

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

import { __assign } from 'tslib';
import addDays from 'date-fns/addDays';

@@ -33,13 +34,29 @@ import addMonths from 'date-fns/addMonths';

var defaultFormats = {
fullDate: "yyyy, MMMM do",
normalDate: "EEE, MMM do",
shortDate: "MMM do",
monthAndDate: "MMMM do",
dayOfMonth: "d",
year: "yyyy",
month: "MMMM",
monthShort: "MMM",
monthAndYear: "MMMM yyyy",
minutes: "mm",
hours12h: "hh",
hours24h: "HH",
seconds: "ss",
fullTime12h: "hh:mm aaa",
fullTime24h: "HH:mm",
fullDateTime12h: "yyyy, MMM do hh:mm aaa",
fullDateTime24h: "yyyy, MMM do HH:mm",
keyboardDate: "yyyy/MM/dd",
keyboardDateTime12h: "yyyy/MM/dd hh:mm aaa",
keyboardDateTime24h: "yyyy/MM/dd HH:mm"
};
var DateFnsUtils = /** @class */ (function () {
function DateFnsUtils(_a) {
var locale = (_a === void 0 ? {} : _a).locale;
this.yearFormat = "yyyy";
this.yearMonthFormat = "MMMM yyyy";
this.dateTime12hFormat = "MMMM do hh:mm aaaa";
this.dateTime24hFormat = "MMMM do HH:mm";
this.time12hFormat = "hh:mm a";
this.time24hFormat = "HH:mm";
this.dateFormat = "MMMM do";
var _b = _a === void 0 ? {} : _a, locale = _b.locale, formats = _b.formats;
this.locale = locale;
this.formats = __assign(__assign({}, defaultFormats), formats);
}

@@ -123,3 +140,6 @@ // Note: date-fns input types are more lenient than this adapter, so we need to expose our more

};
DateFnsUtils.prototype.format = function (date, formatString) {
DateFnsUtils.prototype.format = function (date, formatKey) {
return this.formatByString(date, this.formats[formatKey]);
};
DateFnsUtils.prototype.formatByString = function (date, formatString) {
return format(date, formatString, { locale: this.locale });

@@ -187,3 +207,3 @@ };

end: endOfWeek(now, { locale: this.locale })
}).map(function (day) { return _this.format(day, "EEEEEE"); });
}).map(function (day) { return _this.formatByString(day, "EEEEEE"); });
};

@@ -216,30 +236,2 @@ DateFnsUtils.prototype.getWeekArray = function (date) {

};
// displaying methpds
DateFnsUtils.prototype.getCalendarHeaderText = function (date) {
return this.format(date, this.yearMonthFormat);
};
DateFnsUtils.prototype.getYearText = function (date) {
return this.format(date, "yyyy");
};
DateFnsUtils.prototype.getDatePickerHeaderText = function (date) {
return this.format(date, "EEE, MMM d");
};
DateFnsUtils.prototype.getDateTimePickerHeaderText = function (date) {
return this.format(date, "MMM d");
};
DateFnsUtils.prototype.getMonthText = function (date) {
return this.format(date, "MMMM");
};
DateFnsUtils.prototype.getDayText = function (date) {
return this.format(date, "d");
};
DateFnsUtils.prototype.getHourText = function (date, ampm) {
return this.format(date, ampm ? "hh" : "HH");
};
DateFnsUtils.prototype.getMinuteText = function (date) {
return this.format(date, "mm");
};
DateFnsUtils.prototype.getSecondText = function (date) {
return this.format(date, "ss");
};
return DateFnsUtils;

@@ -246,0 +238,0 @@ }());

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

var tslib = require('tslib');
var addDays = _interopDefault(require('date-fns/addDays'));

@@ -38,13 +39,29 @@ var addMonths = _interopDefault(require('date-fns/addMonths'));

var defaultFormats = {
fullDate: "yyyy, MMMM do",
normalDate: "EEE, MMM do",
shortDate: "MMM do",
monthAndDate: "MMMM do",
dayOfMonth: "d",
year: "yyyy",
month: "MMMM",
monthShort: "MMM",
monthAndYear: "MMMM yyyy",
minutes: "mm",
hours12h: "hh",
hours24h: "HH",
seconds: "ss",
fullTime12h: "hh:mm aaa",
fullTime24h: "HH:mm",
fullDateTime12h: "yyyy, MMM do hh:mm aaa",
fullDateTime24h: "yyyy, MMM do HH:mm",
keyboardDate: "yyyy/MM/dd",
keyboardDateTime12h: "yyyy/MM/dd hh:mm aaa",
keyboardDateTime24h: "yyyy/MM/dd HH:mm"
};
var DateFnsUtils = /** @class */ (function () {
function DateFnsUtils(_a) {
var locale = (_a === void 0 ? {} : _a).locale;
this.yearFormat = "yyyy";
this.yearMonthFormat = "MMMM yyyy";
this.dateTime12hFormat = "MMMM do hh:mm aaaa";
this.dateTime24hFormat = "MMMM do HH:mm";
this.time12hFormat = "hh:mm a";
this.time24hFormat = "HH:mm";
this.dateFormat = "MMMM do";
var _b = _a === void 0 ? {} : _a, locale = _b.locale, formats = _b.formats;
this.locale = locale;
this.formats = tslib.__assign(tslib.__assign({}, defaultFormats), formats);
}

@@ -128,3 +145,6 @@ // Note: date-fns input types are more lenient than this adapter, so we need to expose our more

};
DateFnsUtils.prototype.format = function (date, formatString) {
DateFnsUtils.prototype.format = function (date, formatKey) {
return this.formatByString(date, this.formats[formatKey]);
};
DateFnsUtils.prototype.formatByString = function (date, formatString) {
return format(date, formatString, { locale: this.locale });

@@ -192,3 +212,3 @@ };

end: endOfWeek(now, { locale: this.locale })
}).map(function (day) { return _this.format(day, "EEEEEE"); });
}).map(function (day) { return _this.formatByString(day, "EEEEEE"); });
};

@@ -221,30 +241,2 @@ DateFnsUtils.prototype.getWeekArray = function (date) {

};
// displaying methpds
DateFnsUtils.prototype.getCalendarHeaderText = function (date) {
return this.format(date, this.yearMonthFormat);
};
DateFnsUtils.prototype.getYearText = function (date) {
return this.format(date, "yyyy");
};
DateFnsUtils.prototype.getDatePickerHeaderText = function (date) {
return this.format(date, "EEE, MMM d");
};
DateFnsUtils.prototype.getDateTimePickerHeaderText = function (date) {
return this.format(date, "MMM d");
};
DateFnsUtils.prototype.getMonthText = function (date) {
return this.format(date, "MMMM");
};
DateFnsUtils.prototype.getDayText = function (date) {
return this.format(date, "d");
};
DateFnsUtils.prototype.getHourText = function (date, ampm) {
return this.format(date, ampm ? "hh" : "HH");
};
DateFnsUtils.prototype.getMinuteText = function (date) {
return this.format(date, "mm");
};
DateFnsUtils.prototype.getSecondText = function (date) {
return this.format(date, "ss");
};
return DateFnsUtils;

@@ -251,0 +243,0 @@ }());

{
"name": "@date-io/date-fns",
"version": "1.3.13",
"version": "2.0.0",
"description": "Abstraction over common javascript date management libraries",

@@ -36,3 +36,3 @@ "main": "build/index.js",

"dependencies": {
"@date-io/core": "^1.3.13"
"@date-io/core": "^2.0.0"
},

@@ -44,3 +44,3 @@ "devDependencies": {

},
"gitHead": "d105764c36b2021cde1fbcddd5445fed582a511c"
"gitHead": "29c8f93efe8086a1b5ebb51b0a99d669219d4cbf"
}

@@ -32,28 +32,42 @@ import addDays from "date-fns/addDays";

import startOfYear from "date-fns/startOfYear";
import { IUtils, DateIOFormats } from "@date-io/core/IUtils";
// Locale is not exported from date-fns, so we need to workaround that https://github.com/date-fns/date-fns/issues/932
import SampleLocale from "date-fns/locale/en-US";
import { IUtils } from "@date-io/core/IUtils";
type Locale = typeof import("date-fns/locale/en-US").default;
type Locale = typeof SampleLocale;
const defaultFormats: DateIOFormats = {
fullDate: "yyyy, MMMM do",
normalDate: "EEE, MMM do",
shortDate: "MMM do",
monthAndDate: "MMMM do",
dayOfMonth: "d",
year: "yyyy",
month: "MMMM",
monthShort: "MMM",
monthAndYear: "MMMM yyyy",
minutes: "mm",
hours12h: "hh",
hours24h: "HH",
seconds: "ss",
fullTime12h: "hh:mm aaa",
fullTime24h: "HH:mm",
fullDateTime12h: "yyyy, MMM do hh:mm aaa",
fullDateTime24h: "yyyy, MMM do HH:mm",
keyboardDate: "yyyy/MM/dd",
keyboardDateTime12h: "yyyy/MM/dd hh:mm aaa",
keyboardDateTime24h: "yyyy/MM/dd HH:mm"
};
export default class DateFnsUtils implements IUtils<Date> {
public locale?: Locale;
public formats: DateIOFormats;
public yearFormat = "yyyy";
public yearMonthFormat = "MMMM yyyy";
public dateTime12hFormat = "MMMM do hh:mm aaaa";
public dateTime24hFormat = "MMMM do HH:mm";
public time12hFormat = "hh:mm a";
public time24hFormat = "HH:mm";
public dateFormat = "MMMM do";
constructor({ locale }: { locale?: Locale } = {}) {
constructor({
locale,
formats
}: { formats?: Partial<DateIOFormats>; locale?: Locale } = {}) {
this.locale = locale;
this.formats = {
...defaultFormats,
...formats
};
}

@@ -164,3 +178,7 @@

public format(date: Date, formatString: string) {
public format(date: Date, formatKey: keyof DateIOFormats) {
return this.formatByString(date, this.formats[formatKey]);
}
public formatByString(date: Date, formatString: string) {
return format(date, formatString, { locale: this.locale });

@@ -249,3 +267,3 @@ }

end: endOfWeek(now, { locale: this.locale })
}).map(day => this.format(day, "EEEEEE"));
}).map(day => this.formatByString(day, "EEEEEE"));
}

@@ -285,39 +303,2 @@

}
// displaying methpds
public getCalendarHeaderText(date: Date) {
return this.format(date, this.yearMonthFormat);
}
public getYearText(date: Date) {
return this.format(date, "yyyy");
}
public getDatePickerHeaderText(date: Date) {
return this.format(date, "EEE, MMM d");
}
public getDateTimePickerHeaderText(date: Date) {
return this.format(date, "MMM d");
}
public getMonthText(date: Date) {
return this.format(date, "MMMM");
}
public getDayText(date: Date) {
return this.format(date, "d");
}
public getHourText(date: Date, ampm: boolean) {
return this.format(date, ampm ? "hh" : "HH");
}
public getMinuteText(date: Date) {
return this.format(date, "mm");
}
public getSecondText(date: Date) {
return this.format(date, "ss");
}
}
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