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

php-date-formatter

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

php-date-formatter - npm Package Compare versions

Comparing version 1.3.4 to 1.3.6

.github/CONTRIBUTING.md

2

bower.json
{
"name": "php-date-formatter",
"version": "1.3.4",
"version": "1.3.6",
"homepage": "https://github.com/kartik-v/php-date-formatter",

@@ -5,0 +5,0 @@ "authors": [

Change Log: `php-date-formatter`
================================
## Version 1.3.6
**Date:** 14-Apr-2020
- (enh #24): Correct date format error for characters containing `T`.
- (enh #22): Correct `parseInt` for older browsers.
## Version 1.3.5
**Date:** 13-Jul-2018
- (enh #20, #18): Add UMD support for AMD, node, browser globals.
- (enh #19): Enhance `parseData` for formats where year, month or day is optional.
- (bug #15): Correct ordinal suffix.
- (enh #14): Remove usage of reserved word as function attribute.
- (enh #10): Better handling of escaped characters in string format.
## Version 1.3.4
**Date:** 10-Feb-2016
**Date:** 08-Jan-2017
1. (enh #9): Enhance validation for invalid input date string in `guessDate`.
2. (enh #10, #11): Display escaped characters correctly via `formatDate`.
- (bug #12): Correct hour merdian validation.
- (enh #9): Enhance validation for invalid input date string in `guessDate`.
- Add github contribution and issue/PR logging templates.

@@ -15,3 +33,3 @@ ## Version 1.3.3

1. (bug #7): Fix regexp validation for `formatDate`.
- (bug #7): Fix regexp validation for `formatDate`.

@@ -22,4 +40,4 @@ ## Version 1.3.2

1. (enh #4): Eliminate other JS Library dependency and code enhancements
2. (enh #5): More enhanced and comprehensive PHP date pattern formatting
- (enh #5): More enhanced and comprehensive PHP date pattern formatting
- (enh #4): Eliminate other JS Library dependency and code enhancements

@@ -30,3 +48,3 @@ ## Version 1.3.1

1. (bug #2): Fix conversion to unix timestamp format.
- (bug #2): Fix conversion to unix timestamp format.

@@ -37,14 +55,14 @@ ## Version 1.3.0

1. Set release to stable in composer.json.
2. Updated CHANGE log to reflect user friendly date time formats.
- Set release to stable in composer.json.
- Updated CHANGE log to reflect user friendly date time formats.
## Version 1.2.0
Date: 02-Jul-2014
**Date:** 02-Jul-2014
- Enh #8: Ability to pass additional form input data within each ajax call.
- (enh #8): Ability to pass additional form input data within each ajax call.
## Version 1.1.0
Date: 05-Jul-2014
**Date:** 05-Jul-2014

@@ -58,4 +76,4 @@ - Updated placeholder to accept boolean value (false) to disable it.

Date: 30-Apr-2014
**Date:** 30-Apr-2014
Initial release.

@@ -0,0 +0,0 @@ {

/*!
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2016
* @version 1.3.4
* @copyright Copyright © Kartik Visweswaran, Krajee.com, 2014 - 2020
* @version 1.3.6
*
* Date formatter utility library that allows formatting date/time variables or Date objects using PHP DateTime format.
* This library is a standalone javascript library and does not depend on other libraries or plugins like jQuery. The
* library also adds support for Universal Module Definition (UMD).
*
* @see http://php.net/manual/en/function.date.php

@@ -11,69 +14,93 @@ *

*/
var DateFormatter;
(function () {
"use strict";
var _compare, _lpad, _extend, _indexOf, defaultSettings, DAY, HOUR;
DAY = 1000 * 60 * 60 * 24;
HOUR = 3600;
_compare = function (str1, str2) {
return typeof(str1) === 'string' && typeof(str2) === 'string' && str1.toLowerCase() === str2.toLowerCase();
};
_lpad = function (value, length, char) {
var chr = char || '0', val = value.toString();
return val.length < length ? _lpad(chr + val, length) : val;
};
_extend = function (out) {
var i, obj;
out = out || {};
for (i = 1; i < arguments.length; i++) {
obj = arguments[i];
if (!obj) {
continue;
}
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
if (typeof obj[key] === 'object') {
_extend(out[key], obj[key]);
} else {
out[key] = obj[key];
(function (root, factory) {
// noinspection JSUnresolvedVariable
if (typeof define === 'function' && define.amd) { // AMD
// noinspection JSUnresolvedFunction
define([], factory);
} else {
// noinspection JSUnresolvedVariable
if (typeof module === 'object' && module.exports) { // Node
// noinspection JSUnresolvedVariable
module.exports = factory();
} else { // Browser globals
root.DateFormatter = factory();
}
}
}(typeof self !== 'undefined' ? self : this, function () {
var DateFormatter, $h;
/**
* Global helper object
*/
$h = {
DAY: 1000 * 60 * 60 * 24,
HOUR: 3600,
defaults: {
dateSettings: {
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
daysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
months: [
'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December'
],
monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
meridiem: ['AM', 'PM'],
ordinal: function (number) {
var n = number % 10, suffixes = {1: 'st', 2: 'nd', 3: 'rd'};
return Math.floor(number % 100 / 10) === 1 || !suffixes[n] ? 'th' : suffixes[n];
}
},
separators: /[ \-+\/.:@]/g,
validParts: /[dDjlNSwzWFmMntLoYyaABgGhHisueTIOPZcrU]/g,
intParts: /[djwNzmnyYhHgGis]/g,
tzParts: /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
tzClip: /[^-+\dA-Z]/g
},
getInt: function (str, radix) {
return parseInt(str, (radix ? radix : 10));
},
compare: function (str1, str2) {
return typeof (str1) === 'string' && typeof (str2) === 'string' && str1.toLowerCase() === str2.toLowerCase();
},
lpad: function (value, length, chr) {
var val = value.toString();
chr = chr || '0';
return val.length < length ? $h.lpad(chr + val, length) : val;
},
merge: function (out) {
var i, obj;
out = out || {};
for (i = 1; i < arguments.length; i++) {
obj = arguments[i];
if (!obj) {
continue;
}
for (var key in obj) {
if (obj.hasOwnProperty(key)) {
if (typeof obj[key] === 'object') {
$h.merge(out[key], obj[key]);
} else {
out[key] = obj[key];
}
}
}
}
}
return out;
};
_indexOf = function (val, arr) {
for (var i = 0; i < arr.length; i++) {
if (arr[i].toLowerCase() === val.toLowerCase()) {
return i;
return out;
},
getIndex: function (val, arr) {
for (var i = 0; i < arr.length; i++) {
if (arr[i].toLowerCase() === val.toLowerCase()) {
return i;
}
}
return -1;
}
return -1;
};
defaultSettings = {
dateSettings: {
days: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'],
daysShort: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
months: [
'January', 'February', 'March', 'April', 'May', 'June', 'July',
'August', 'September', 'October', 'November', 'December'
],
monthsShort: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'],
meridiem: ['AM', 'PM'],
ordinal: function (number) {
var n = number % 10, suffixes = {1: 'st', 2: 'nd', 3: 'rd'};
return Math.floor(number % 100 / 10) === 1 || !suffixes[n] ? 'th' : suffixes[n];
}
},
separators: /[ \-+\/\.T:@]/g,
validParts: /[dDjlNSwzWFmMntLoYyaABgGhHisueTIOPZcrU]/g,
intParts: /[djwNzmnyYhHgGis]/g,
tzParts: /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
tzClip: /[^-+\dA-Z]/g
};
/**
* Date Formatter Library Constructor
* @param options
* @constructor
*/
DateFormatter = function (options) {
var self = this, config = _extend(defaultSettings, options);
var self = this, config = $h.merge($h.defaults, options);
self.dateSettings = config.dateSettings;

@@ -87,2 +114,5 @@ self.separators = config.separators;

/**
* DateFormatter Library Prototype
*/
DateFormatter.prototype = {

@@ -92,5 +122,5 @@ constructor: DateFormatter,

var self = this, i;
i = _indexOf(val, self.dateSettings.monthsShort) + 1;
i = $h.getIndex(val, self.dateSettings.monthsShort) + 1;
if (i === 0) {
i = _indexOf(val, self.dateSettings.months) + 1;
i = $h.getIndex(val, self.dateSettings.months) + 1;
}

@@ -110,3 +140,3 @@ return i;

if (vFormat === 'U') {
i = parseInt(vDate);
i = $h.getInt(vDate);
return i ? new Date(i * 1000) : vDate;

@@ -124,8 +154,13 @@ }

if (!vFormatParts || vFormatParts.length === 0) {
throw new Error("Invalid date format definition.");
throw new Error('Invalid date format definition.');
}
for (i = vFormatParts.length - 1; i >= 0; i--) {
if (vFormatParts[i] === 'S') {
vFormatParts.splice(i, 1);
}
}
vDateParts = vDate.replace(self.separators, '\0').split('\0');
for (i = 0; i < vDateParts.length; i++) {
vDatePart = vDateParts[i];
iDatePart = parseInt(vDatePart);
iDatePart = $h.getInt(vDatePart);
switch (vFormatParts[i]) {

@@ -136,3 +171,3 @@ case 'y':

len = vDatePart.length;
out.year = len === 2 ? parseInt((iDatePart < 70 ? '20' : '19') + vDatePart) : iDatePart;
out.year = len === 2 ? $h.getInt((iDatePart < 70 ? '20' : '19') + vDatePart) : iDatePart;
} else {

@@ -175,11 +210,13 @@ return null;

vMeriIndex = (vFormatParts.indexOf('a') > -1) ? vFormatParts.indexOf('a') :
(vFormatParts.indexOf('A') > -1) ? vFormatParts.indexOf('A') : -1;
((vFormatParts.indexOf('A') > -1) ? vFormatParts.indexOf('A') : -1);
mer = vDateParts[vMeriIndex];
if (vMeriIndex > -1) {
vMeriOffset = _compare(mer, vSettings.meridiem[0]) ? 0 :
(_compare(mer, vSettings.meridiem[1]) ? 12 : -1);
if (iDatePart >= 1 && iDatePart <= 12 && vMeriOffset > -1) {
out.hour = iDatePart + vMeriOffset - 1;
} else if (iDatePart >= 0 && iDatePart <= 23) {
out.hour = iDatePart;
if (vMeriIndex !== -1) {
vMeriOffset = $h.compare(mer, vSettings.meridiem[0]) ? 0 :
($h.compare(mer, vSettings.meridiem[1]) ? 12 : -1);
if (iDatePart >= 1 && iDatePart <= 12 && vMeriOffset !== -1) {
out.hour = iDatePart % 12 === 0 ? vMeriOffset : iDatePart + vMeriOffset;
} else {
if (iDatePart >= 0 && iDatePart <= 23) {
out.hour = iDatePart;
}
}

@@ -222,4 +259,5 @@ } else {

}
if (vDateFlag === true && out.year && out.month && out.day) {
out.date = new Date(out.year, out.month - 1, out.day, out.hour, out.min, out.sec, 0);
if (vDateFlag === true) {
var varY = out.year || 0, varM = out.month ? out.month - 1 : 0, varD = out.day || 1;
out.date = new Date(varY, varM, varD, out.hour, out.min, out.sec, 0);
} else {

@@ -247,3 +285,3 @@ if (vTimeFlag !== true) {

iPart = vParts[i];
iSec = parseInt(iPart.substr(0, 2));
iSec = $h.getInt(iPart.substr(0, 2));
if (isNaN(iSec)) {

@@ -271,3 +309,3 @@ return null;

vDigit = len < 4 ? len : 4;
vYear = parseInt(len < 4 ? vYear.toString().substr(0, 4 - len) + iPart : iPart.substr(0, 4));
vYear = $h.getInt(len < 4 ? vYear.toString().substr(0, 4 - len) + iPart : iPart.substr(0, 4));
if (!vYear) {

@@ -308,3 +346,3 @@ return null;

d: function () {
return _lpad(fmt.j(), 2);
return $h.lpad(fmt.j(), 2);
},

@@ -327,3 +365,3 @@ /**

* Full day name: `Monday...Sunday`
* @return {number}
* @return {string}
*/

@@ -353,3 +391,3 @@ l: function () {

var a = new Date(fmt.Y(), fmt.n() - 1, fmt.j()), b = new Date(fmt.Y(), 0, 1);
return Math.round((a - b) / DAY);
return Math.round((a - b) / $h.DAY);
},

@@ -366,3 +404,3 @@

var a = new Date(fmt.Y(), fmt.n() - 1, fmt.j() - fmt.N() + 3), b = new Date(a.getFullYear(), 0, 4);
return _lpad(1 + Math.round((a - b) / DAY / 7), 2);
return $h.lpad(1 + Math.round((a - b) / $h.DAY / 7), 2);
},

@@ -385,3 +423,3 @@

m: function () {
return _lpad(fmt.n(), 2);
return $h.lpad(fmt.n(), 2);
},

@@ -467,4 +505,4 @@ /**

B: function () {
var H = vDate.getUTCHours() * HOUR, i = vDate.getUTCMinutes() * 60, s = vDate.getUTCSeconds();
return _lpad(Math.floor((H + i + s + HOUR) / 86.4) % 1000, 3);
var H = vDate.getUTCHours() * $h.HOUR, i = vDate.getUTCMinutes() * 60, s = vDate.getUTCSeconds();
return $h.lpad(Math.floor((H + i + s + $h.HOUR) / 86.4) % 1000, 3);
},

@@ -490,3 +528,3 @@ /**

h: function () {
return _lpad(fmt.g(), 2);
return $h.lpad(fmt.g(), 2);
},

@@ -498,3 +536,3 @@ /**

H: function () {
return _lpad(fmt.G(), 2);
return $h.lpad(fmt.G(), 2);
},

@@ -506,3 +544,3 @@ /**

i: function () {
return _lpad(vDate.getMinutes(), 2);
return $h.lpad(vDate.getMinutes(), 2);
},

@@ -514,3 +552,3 @@ /**

s: function () {
return _lpad(vDate.getSeconds(), 2);
return $h.lpad(vDate.getSeconds(), 2);
},

@@ -522,3 +560,3 @@ /**

u: function () {
return _lpad(vDate.getMilliseconds() * 1000, 6);
return $h.lpad(vDate.getMilliseconds() * 1000, 6);
},

@@ -552,3 +590,3 @@

var tzo = vDate.getTimezoneOffset(), a = Math.abs(tzo);
return (tzo > 0 ? '-' : '+') + _lpad(Math.floor(a / 60) * 100 + a % 60, 4);
return (tzo > 0 ? '-' : '+') + $h.lpad(Math.floor(a / 60) * 100 + a % 60, 4);
},

@@ -568,3 +606,3 @@ /**

T: function () {
var str = (String(vDate).match(self.tzParts) || [""]).pop().replace(self.tzClip, "");
var str = (String(vDate).match(self.tzParts) || ['']).pop().replace(self.tzClip, '');
return str || 'UTC';

@@ -628,3 +666,3 @@ },

if (i !== (len - 1) && self.intParts.test(vChar) && vFormat.charAt(i + 1) === 'S') {
n = parseInt(str) || 0;
n = $h.getInt(str) || 0;
str += self.dateSettings.ordinal(n);

@@ -639,2 +677,3 @@ }

};
})();
return DateFormatter;
}));
/*!
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2016
* @version 1.3.4
* @copyright Copyright &copy; Kartik Visweswaran, Krajee.com, 2014 - 2020
* @version 1.3.6
*
* Date formatter utility library that allows formatting date/time variables or Date objects using PHP DateTime format.
* This library is a standalone javascript library and does not depend on other libraries or plugins like jQuery. The
* library also adds support for Universal Module Definition (UMD).
*
* @see http://php.net/manual/en/function.date.php

@@ -10,2 +13,2 @@ *

* For more Yii related demos visit http://demos.krajee.com
*/var DateFormatter;!function(){"use strict";var t,e,r,n,a,u,i;u=864e5,i=3600,t=function(t,e){return"string"==typeof t&&"string"==typeof e&&t.toLowerCase()===e.toLowerCase()},e=function(t,r,n){var a=n||"0",u=t.toString();return u.length<r?e(a+u,r):u},r=function(t){var e,n;for(t=t||{},e=1;e<arguments.length;e++)if(n=arguments[e])for(var a in n)n.hasOwnProperty(a)&&("object"==typeof n[a]?r(t[a],n[a]):t[a]=n[a]);return t},n=function(t,e){for(var r=0;r<e.length;r++)if(e[r].toLowerCase()===t.toLowerCase())return r;return-1},a={dateSettings:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],meridiem:["AM","PM"],ordinal:function(t){var e=t%10,r={1:"st",2:"nd",3:"rd"};return 1!==Math.floor(t%100/10)&&r[e]?r[e]:"th"}},separators:/[ \-+\/\.T:@]/g,validParts:/[dDjlNSwzWFmMntLoYyaABgGhHisueTIOPZcrU]/g,intParts:/[djwNzmnyYhHgGis]/g,tzParts:/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,tzClip:/[^-+\dA-Z]/g},DateFormatter=function(t){var e=this,n=r(a,t);e.dateSettings=n.dateSettings,e.separators=n.separators,e.validParts=n.validParts,e.intParts=n.intParts,e.tzParts=n.tzParts,e.tzClip=n.tzClip},DateFormatter.prototype={constructor:DateFormatter,getMonth:function(t){var e,r=this;return e=n(t,r.dateSettings.monthsShort)+1,0===e&&(e=n(t,r.dateSettings.months)+1),e},parseDate:function(e,r){var n,a,u,i,s,o,c,f,l,h,d=this,g=!1,m=!1,p=d.dateSettings,y={date:null,year:null,month:null,day:null,hour:0,min:0,sec:0};if(!e)return null;if(e instanceof Date)return e;if("U"===r)return u=parseInt(e),u?new Date(1e3*u):e;switch(typeof e){case"number":return new Date(e);case"string":break;default:return null}if(n=r.match(d.validParts),!n||0===n.length)throw new Error("Invalid date format definition.");for(a=e.replace(d.separators,"\x00").split("\x00"),u=0;u<a.length;u++)switch(i=a[u],s=parseInt(i),n[u]){case"y":case"Y":if(!s)return null;l=i.length,y.year=2===l?parseInt((70>s?"20":"19")+i):s,g=!0;break;case"m":case"n":case"M":case"F":if(isNaN(s)){if(o=d.getMonth(i),!(o>0))return null;y.month=o}else{if(!(s>=1&&12>=s))return null;y.month=s}g=!0;break;case"d":case"j":if(!(s>=1&&31>=s))return null;y.day=s,g=!0;break;case"g":case"h":if(c=n.indexOf("a")>-1?n.indexOf("a"):n.indexOf("A")>-1?n.indexOf("A"):-1,h=a[c],c>-1)f=t(h,p.meridiem[0])?0:t(h,p.meridiem[1])?12:-1,s>=1&&12>=s&&f>-1?y.hour=s+f-1:s>=0&&23>=s&&(y.hour=s);else{if(!(s>=0&&23>=s))return null;y.hour=s}m=!0;break;case"G":case"H":if(!(s>=0&&23>=s))return null;y.hour=s,m=!0;break;case"i":if(!(s>=0&&59>=s))return null;y.min=s,m=!0;break;case"s":if(!(s>=0&&59>=s))return null;y.sec=s,m=!0}if(g===!0&&y.year&&y.month&&y.day)y.date=new Date(y.year,y.month-1,y.day,y.hour,y.min,y.sec,0);else{if(m!==!0)return null;y.date=new Date(0,0,0,y.hour,y.min,y.sec,0)}return y.date},guessDate:function(t,e){if("string"!=typeof t)return t;var r,n,a,u,i,s,o=this,c=t.replace(o.separators,"\x00").split("\x00"),f=/^[djmn]/g,l=e.match(o.validParts),h=new Date,d=0;if(!f.test(l[0]))return t;for(a=0;a<c.length;a++){if(d=2,i=c[a],s=parseInt(i.substr(0,2)),isNaN(s))return null;switch(a){case 0:"m"===l[0]||"n"===l[0]?h.setMonth(s-1):h.setDate(s);break;case 1:"m"===l[0]||"n"===l[0]?h.setDate(s):h.setMonth(s-1);break;case 2:if(n=h.getFullYear(),r=i.length,d=4>r?r:4,n=parseInt(4>r?n.toString().substr(0,4-r)+i:i.substr(0,4)),!n)return null;h.setFullYear(n);break;case 3:h.setHours(s);break;case 4:h.setMinutes(s);break;case 5:h.setSeconds(s)}u=i.substr(d),u.length>0&&c.splice(a+1,0,u)}return h},parseFormat:function(t,r){var n,a=this,s=a.dateSettings,o=/\\?(.?)/gi,c=function(t,e){return n[t]?n[t]():e};return n={d:function(){return e(n.j(),2)},D:function(){return s.daysShort[n.w()]},j:function(){return r.getDate()},l:function(){return s.days[n.w()]},N:function(){return n.w()||7},w:function(){return r.getDay()},z:function(){var t=new Date(n.Y(),n.n()-1,n.j()),e=new Date(n.Y(),0,1);return Math.round((t-e)/u)},W:function(){var t=new Date(n.Y(),n.n()-1,n.j()-n.N()+3),r=new Date(t.getFullYear(),0,4);return e(1+Math.round((t-r)/u/7),2)},F:function(){return s.months[r.getMonth()]},m:function(){return e(n.n(),2)},M:function(){return s.monthsShort[r.getMonth()]},n:function(){return r.getMonth()+1},t:function(){return new Date(n.Y(),n.n(),0).getDate()},L:function(){var t=n.Y();return t%4===0&&t%100!==0||t%400===0?1:0},o:function(){var t=n.n(),e=n.W(),r=n.Y();return r+(12===t&&9>e?1:1===t&&e>9?-1:0)},Y:function(){return r.getFullYear()},y:function(){return n.Y().toString().slice(-2)},a:function(){return n.A().toLowerCase()},A:function(){var t=n.G()<12?0:1;return s.meridiem[t]},B:function(){var t=r.getUTCHours()*i,n=60*r.getUTCMinutes(),a=r.getUTCSeconds();return e(Math.floor((t+n+a+i)/86.4)%1e3,3)},g:function(){return n.G()%12||12},G:function(){return r.getHours()},h:function(){return e(n.g(),2)},H:function(){return e(n.G(),2)},i:function(){return e(r.getMinutes(),2)},s:function(){return e(r.getSeconds(),2)},u:function(){return e(1e3*r.getMilliseconds(),6)},e:function(){var t=/\((.*)\)/.exec(String(r))[1];return t||"Coordinated Universal Time"},I:function(){var t=new Date(n.Y(),0),e=Date.UTC(n.Y(),0),r=new Date(n.Y(),6),a=Date.UTC(n.Y(),6);return t-e!==r-a?1:0},O:function(){var t=r.getTimezoneOffset(),n=Math.abs(t);return(t>0?"-":"+")+e(100*Math.floor(n/60)+n%60,4)},P:function(){var t=n.O();return t.substr(0,3)+":"+t.substr(3,2)},T:function(){var t=(String(r).match(a.tzParts)||[""]).pop().replace(a.tzClip,"");return t||"UTC"},Z:function(){return 60*-r.getTimezoneOffset()},c:function(){return"Y-m-d\\TH:i:sP".replace(o,c)},r:function(){return"D, d M Y H:i:s O".replace(o,c)},U:function(){return r.getTime()/1e3||0}},c(t,t)},formatDate:function(t,e){var r,n,a,u,i,s=this,o="",c="\\";if("string"==typeof t&&(t=s.parseDate(t,e),!t))return null;if(t instanceof Date){for(a=e.length,r=0;a>r;r++)i=e.charAt(r),"S"!==i&&i!==c&&(r>0&&e.charAt(r-1)===c?o+=i:(u=s.parseFormat(i,t),r!==a-1&&s.intParts.test(i)&&"S"===e.charAt(r+1)&&(n=parseInt(u)||0,u+=s.dateSettings.ordinal(n)),o+=u));return o}return""}}}();
*/!function(t,e){"function"==typeof define&&define.amd?define([],e):"object"==typeof module&&module.exports?module.exports=e():t.DateFormatter=e()}("undefined"!=typeof self?self:this,function(){var t,e;return e={DAY:864e5,HOUR:3600,defaults:{dateSettings:{days:["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],daysShort:["Sun","Mon","Tue","Wed","Thu","Fri","Sat"],months:["January","February","March","April","May","June","July","August","September","October","November","December"],monthsShort:["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"],meridiem:["AM","PM"],ordinal:function(t){var e=t%10,n={1:"st",2:"nd",3:"rd"};return 1!==Math.floor(t%100/10)&&n[e]?n[e]:"th"}},separators:/[ \-+\/.:@]/g,validParts:/[dDjlNSwzWFmMntLoYyaABgGhHisueTIOPZcrU]/g,intParts:/[djwNzmnyYhHgGis]/g,tzParts:/\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,tzClip:/[^-+\dA-Z]/g},getInt:function(t,e){return parseInt(t,e?e:10)},compare:function(t,e){return"string"==typeof t&&"string"==typeof e&&t.toLowerCase()===e.toLowerCase()},lpad:function(t,n,r){var a=t.toString();return r=r||"0",a.length<n?e.lpad(r+a,n):a},merge:function(t){var n,r;for(t=t||{},n=1;n<arguments.length;n++)if(r=arguments[n])for(var a in r)r.hasOwnProperty(a)&&("object"==typeof r[a]?e.merge(t[a],r[a]):t[a]=r[a]);return t},getIndex:function(t,e){for(var n=0;n<e.length;n++)if(e[n].toLowerCase()===t.toLowerCase())return n;return-1}},t=function(t){var n=this,r=e.merge(e.defaults,t);n.dateSettings=r.dateSettings,n.separators=r.separators,n.validParts=r.validParts,n.intParts=r.intParts,n.tzParts=r.tzParts,n.tzClip=r.tzClip},t.prototype={constructor:t,getMonth:function(t){var n,r=this;return n=e.getIndex(t,r.dateSettings.monthsShort)+1,0===n&&(n=e.getIndex(t,r.dateSettings.months)+1),n},parseDate:function(t,n){var r,a,u,i,o,s,c,f,l,d,g=this,h=!1,m=!1,p=g.dateSettings,y={date:null,year:null,month:null,day:null,hour:0,min:0,sec:0};if(!t)return null;if(t instanceof Date)return t;if("U"===n)return u=e.getInt(t),u?new Date(1e3*u):t;switch(typeof t){case"number":return new Date(t);case"string":break;default:return null}if(r=n.match(g.validParts),!r||0===r.length)throw new Error("Invalid date format definition.");for(u=r.length-1;u>=0;u--)"S"===r[u]&&r.splice(u,1);for(a=t.replace(g.separators,"\x00").split("\x00"),u=0;u<a.length;u++)switch(i=a[u],o=e.getInt(i),r[u]){case"y":case"Y":if(!o)return null;l=i.length,y.year=2===l?e.getInt((70>o?"20":"19")+i):o,h=!0;break;case"m":case"n":case"M":case"F":if(isNaN(o)){if(s=g.getMonth(i),!(s>0))return null;y.month=s}else{if(!(o>=1&&12>=o))return null;y.month=o}h=!0;break;case"d":case"j":if(!(o>=1&&31>=o))return null;y.day=o,h=!0;break;case"g":case"h":if(c=r.indexOf("a")>-1?r.indexOf("a"):r.indexOf("A")>-1?r.indexOf("A"):-1,d=a[c],-1!==c)f=e.compare(d,p.meridiem[0])?0:e.compare(d,p.meridiem[1])?12:-1,o>=1&&12>=o&&-1!==f?y.hour=o%12===0?f:o+f:o>=0&&23>=o&&(y.hour=o);else{if(!(o>=0&&23>=o))return null;y.hour=o}m=!0;break;case"G":case"H":if(!(o>=0&&23>=o))return null;y.hour=o,m=!0;break;case"i":if(!(o>=0&&59>=o))return null;y.min=o,m=!0;break;case"s":if(!(o>=0&&59>=o))return null;y.sec=o,m=!0}if(h===!0){var D=y.year||0,v=y.month?y.month-1:0,S=y.day||1;y.date=new Date(D,v,S,y.hour,y.min,y.sec,0)}else{if(m!==!0)return null;y.date=new Date(0,0,0,y.hour,y.min,y.sec,0)}return y.date},guessDate:function(t,n){if("string"!=typeof t)return t;var r,a,u,i,o,s,c=this,f=t.replace(c.separators,"\x00").split("\x00"),l=/^[djmn]/g,d=n.match(c.validParts),g=new Date,h=0;if(!l.test(d[0]))return t;for(u=0;u<f.length;u++){if(h=2,o=f[u],s=e.getInt(o.substr(0,2)),isNaN(s))return null;switch(u){case 0:"m"===d[0]||"n"===d[0]?g.setMonth(s-1):g.setDate(s);break;case 1:"m"===d[0]||"n"===d[0]?g.setDate(s):g.setMonth(s-1);break;case 2:if(a=g.getFullYear(),r=o.length,h=4>r?r:4,a=e.getInt(4>r?a.toString().substr(0,4-r)+o:o.substr(0,4)),!a)return null;g.setFullYear(a);break;case 3:g.setHours(s);break;case 4:g.setMinutes(s);break;case 5:g.setSeconds(s)}i=o.substr(h),i.length>0&&f.splice(u+1,0,i)}return g},parseFormat:function(t,n){var r,a=this,u=a.dateSettings,i=/\\?(.?)/gi,o=function(t,e){return r[t]?r[t]():e};return r={d:function(){return e.lpad(r.j(),2)},D:function(){return u.daysShort[r.w()]},j:function(){return n.getDate()},l:function(){return u.days[r.w()]},N:function(){return r.w()||7},w:function(){return n.getDay()},z:function(){var t=new Date(r.Y(),r.n()-1,r.j()),n=new Date(r.Y(),0,1);return Math.round((t-n)/e.DAY)},W:function(){var t=new Date(r.Y(),r.n()-1,r.j()-r.N()+3),n=new Date(t.getFullYear(),0,4);return e.lpad(1+Math.round((t-n)/e.DAY/7),2)},F:function(){return u.months[n.getMonth()]},m:function(){return e.lpad(r.n(),2)},M:function(){return u.monthsShort[n.getMonth()]},n:function(){return n.getMonth()+1},t:function(){return new Date(r.Y(),r.n(),0).getDate()},L:function(){var t=r.Y();return t%4===0&&t%100!==0||t%400===0?1:0},o:function(){var t=r.n(),e=r.W(),n=r.Y();return n+(12===t&&9>e?1:1===t&&e>9?-1:0)},Y:function(){return n.getFullYear()},y:function(){return r.Y().toString().slice(-2)},a:function(){return r.A().toLowerCase()},A:function(){var t=r.G()<12?0:1;return u.meridiem[t]},B:function(){var t=n.getUTCHours()*e.HOUR,r=60*n.getUTCMinutes(),a=n.getUTCSeconds();return e.lpad(Math.floor((t+r+a+e.HOUR)/86.4)%1e3,3)},g:function(){return r.G()%12||12},G:function(){return n.getHours()},h:function(){return e.lpad(r.g(),2)},H:function(){return e.lpad(r.G(),2)},i:function(){return e.lpad(n.getMinutes(),2)},s:function(){return e.lpad(n.getSeconds(),2)},u:function(){return e.lpad(1e3*n.getMilliseconds(),6)},e:function(){var t=/\((.*)\)/.exec(String(n))[1];return t||"Coordinated Universal Time"},I:function(){var t=new Date(r.Y(),0),e=Date.UTC(r.Y(),0),n=new Date(r.Y(),6),a=Date.UTC(r.Y(),6);return t-e!==n-a?1:0},O:function(){var t=n.getTimezoneOffset(),r=Math.abs(t);return(t>0?"-":"+")+e.lpad(100*Math.floor(r/60)+r%60,4)},P:function(){var t=r.O();return t.substr(0,3)+":"+t.substr(3,2)},T:function(){var t=(String(n).match(a.tzParts)||[""]).pop().replace(a.tzClip,"");return t||"UTC"},Z:function(){return 60*-n.getTimezoneOffset()},c:function(){return"Y-m-d\\TH:i:sP".replace(i,o)},r:function(){return"D, d M Y H:i:s O".replace(i,o)},U:function(){return n.getTime()/1e3||0}},o(t,t)},formatDate:function(t,n){var r,a,u,i,o,s=this,c="",f="\\";if("string"==typeof t&&(t=s.parseDate(t,n),!t))return null;if(t instanceof Date){for(u=n.length,r=0;u>r;r++)o=n.charAt(r),"S"!==o&&o!==f&&(r>0&&n.charAt(r-1)===f?c+=o:(i=s.parseFormat(o,t),r!==u-1&&s.intParts.test(o)&&"S"===n.charAt(r+1)&&(a=e.getInt(i)||0,i+=s.dateSettings.ordinal(a)),c+=i));return c}return""}},t});

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

Copyright (c) 2014 - 2016, Kartik Visweswaran
Copyright (c) 2014 - 2020, Kartik Visweswaran
Krajee.com

@@ -3,0 +3,0 @@ All rights reserved.

{
"name": "php-date-formatter",
"version": "1.3.4",
"version": "1.3.6",
"description": "A Javascript datetime formatting and manipulation library using PHP date-time formats.",

@@ -5,0 +5,0 @@ "main": "js/php-date-formatter.js",

@@ -1,5 +0,15 @@

php-date-formatter
==================
<h1 align="center">
<a href="http://plugins.krajee.com" title="Krajee Plugins" target="_blank">
<img src="http://kartik-v.github.io/bootstrap-fileinput-samples/samples/krajee-logo-b.png" alt="Krajee Logo"/>
</a>
<br>
php-date-formatter
<hr>
<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=DTP3NZQ6G2AYU"
title="Donate via Paypal" target="_blank">
<img src="http://kartik-v.github.io/bootstrap-fileinput-samples/samples/donate.png" alt="Donate"/>
</a>
</h1>
[![BOWER version](https://badge-me.herokuapp.com/api/bower/kartik-v/php-date-formatter.png)](http://badges.enytc.com/for/bower/kartik-v/php-date-formatter)
[![Bower version](https://badge.fury.io/bo/php-date-formatter.svg)](http://badge.fury.io/bo/php-date-formatter)
[![Stable Version](https://poser.pugx.org/kartik-v/php-date-formatter/v/stable)](https://packagist.org/packages/kartik-v/php-date-formatter)

@@ -16,4 +26,6 @@ [![Unstable Version](https://poser.pugx.org/kartik-v/php-date-formatter/v/unstable)](https://packagist.org/packages/kartik-v/php-date-formatter)

The latest release of the library is v1.3.4. Check the [CHANGE LOG](https://github.com/kartik-v/php-date-formatter/blob/master/CHANGE.md) for details.
This library is a standalone javascript library and does not depend on other libraries or plugins like jQuery.
The latest release of the library is v1.3.6. Check the [CHANGE LOG](https://github.com/kartik-v/php-date-formatter/blob/master/CHANGE.md) for details.
## Features

@@ -20,0 +32,0 @@

Sorry, the diff of this file is not supported yet

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