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

date-format-parse

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

date-format-parse - npm Package Compare versions

Comparing version 0.2.3 to 0.2.4

9

CHANGELOG.md

@@ -0,1 +1,10 @@

## [0.2.4](https://github.com/mengxiong10/date-format-parse/compare/v0.2.3...v0.2.4) (2019-11-11)
### Bug Fixes
* negative year ([dad4e83](https://github.com/mengxiong10/date-format-parse/commit/dad4e833a885470e530f4d0165d0ed0de5b9d15e))
## [0.2.3](https://github.com/mengxiong10/date-format-parse/compare/v0.2.2...v0.2.3) (2019-11-10)

@@ -2,0 +11,0 @@

11

es/format.js
import { toDate, isValidDate, getWeek } from './util';
import defaultLocale from './locale/en';
var REGEX_FORMAT = /\[([^\]]+)]|YY(?:YY)?|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|m{1,2}|s{1,2}|Z{1,2}|S{1,3}|w{1,2}|x|X|a|A/g;
var REGEX_FORMAT = /\[([^\]]+)]|YYYY|YY?|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|m{1,2}|s{1,2}|Z{1,2}|S{1,3}|w{1,2}|x|X|a|A/g;
function pad(val) {
var len = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
var output = Math.abs(val).toString();
var output = "".concat(Math.abs(val));
var sign = val < 0 ? '-' : '';

@@ -13,3 +14,3 @@ while (output.length < len) {

return output;
return sign + output;
}

@@ -32,2 +33,6 @@

var formatFlags = {
Y: function Y(date) {
var y = date.getFullYear();
return y <= 9999 ? "".concat(y) : "+".concat(y);
},
// Year: 00, 01, ..., 99

@@ -34,0 +39,0 @@ YY: function YY(date) {

@@ -89,2 +89,3 @@ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }

addParseFlag('Y', matchSigned, YEAR);
addParseFlag('YY', match2, function (input) {

@@ -91,0 +92,0 @@ var year = new Date().getFullYear();

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

var REGEX_FORMAT = /\[([^\]]+)]|YY(?:YY)?|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|m{1,2}|s{1,2}|Z{1,2}|S{1,3}|w{1,2}|x|X|a|A/g;
var REGEX_FORMAT = /\[([^\]]+)]|YYYY|YY?|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|m{1,2}|s{1,2}|Z{1,2}|S{1,3}|w{1,2}|x|X|a|A/g;
function pad(val) {
var len = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 2;
var output = Math.abs(val).toString();
var output = "".concat(Math.abs(val));
var sign = val < 0 ? '-' : '';

@@ -25,3 +26,3 @@ while (output.length < len) {

return output;
return sign + output;
}

@@ -44,2 +45,6 @@

var formatFlags = {
Y: function Y(date) {
var y = date.getFullYear();
return y <= 9999 ? "".concat(y) : "+".concat(y);
},
// Year: 00, 01, ..., 99

@@ -46,0 +51,0 @@ YY: function YY(date) {

@@ -100,2 +100,3 @@ "use strict";

addParseFlag('Y', matchSigned, YEAR);
addParseFlag('YY', match2, function (input) {

@@ -102,0 +103,0 @@ var year = new Date().getFullYear();

{
"name": "date-format-parse",
"version": "0.2.3",
"version": "0.2.4",
"description": "Lightweight date format and parse",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -5,10 +5,11 @@ import { toDate, isValidDate, getWeek } from './util';

const REGEX_FORMAT = /\[([^\]]+)]|YY(?:YY)?|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|m{1,2}|s{1,2}|Z{1,2}|S{1,3}|w{1,2}|x|X|a|A/g;
const REGEX_FORMAT = /\[([^\]]+)]|YYYY|YY?|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|m{1,2}|s{1,2}|Z{1,2}|S{1,3}|w{1,2}|x|X|a|A/g;
function pad(val: number, len = 2) {
let output: string = Math.abs(val).toString();
let output = `${Math.abs(val)}`;
const sign = val < 0 ? '-' : '';
while (output.length < len) {
output = `0${output}`;
}
return output;
return sign + output;
}

@@ -34,2 +35,7 @@

const formatFlags: FormatFlag = {
Y(date) {
const y = date.getFullYear();
return y <= 9999 ? `${y}` : `+${y}`;
},
// Year: 00, 01, ..., 99

@@ -36,0 +42,0 @@ YY(date) {

@@ -88,2 +88,3 @@ import { Unionize, PickByValue } from 'utility-types';

addParseFlag('Y', matchSigned, YEAR);
addParseFlag('YY', match2, input => {

@@ -90,0 +91,0 @@ const year = new Date().getFullYear();

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