Safari does not understand new Date(YYYY-MM-DD HH:MM:SS)

master
Vitaliy Filippov 2018-12-04 00:18:50 +03:00
parent 95af62423c
commit 843ed7c889
7 changed files with 22 additions and 22 deletions

View File

@ -73,22 +73,22 @@ export class Calendar extends preact.Component
{ {
var i = this.props.input; var i = this.props.input;
var t = i.value.split(/\s+/, 2)[1]||''; var t = i.value.split(/\s+/, 2)[1]||'';
if (t)
t = ' '+t;
month = Number(month)+1; month = Number(month)+1;
if (month < 10)
month = '0'+month;
if (day < 10)
day = '0'+day;
if (this.props.callback) if (this.props.callback)
{ {
// Safari does not understand new Date('YYYY-MM-DD HH:MM:SS')
t = t ? t.split(/:/) : null;
t = t ? new Date(year-0, month-1, day-0, t[0]-0, t[1]-0, t[2]-0) : new Date(year-0, month-1, day-0);
var c = this.props.callback; var c = this.props.callback;
t = year + '-' + month + '-' + day + t;
c(new Date(t)); c(new Date(t));
} }
else else
{ {
t = (this.format == 'Y-m-d' ? year + '-' + month + '-' + day : day + '.' + month + '.' + year) + t; if (month < 10)
month = '0'+month;
if (day < 10)
day = '0'+day;
t = (this.format == 'Y-m-d' ? year + '-' + month + '-' + day : day + '.' + month + '.' + year) + (t ? ' '+t : '');
i.value = t; i.value = t;
if ("Event" in window) if ("Event" in window)
{ {

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -81,18 +81,18 @@ export class Calendar
selectDate(year, month, day) selectDate(year, month, day)
{ {
var i = this.input; var i = this.input;
var t = i.value.split(/\s+/, 2)[1]||''; var t = i.value.split(/[\s]+/, 2)[1]||'';
if (t)
t = ' '+t;
if (this.callback) if (this.callback)
{ {
// Safari does not understand new Date('YYYY-MM-DD HH:MM:SS')
t = t ? t.split(/:/) : null;
t = t ? new Date(year-0, month-1, day-0, t[0]-0, t[1]-0, t[2]-0) : new Date(year-0, month-1, day-0);
var c = this.callback; var c = this.callback;
t = year + '-' + month + '-' + day + t; c(t);
c(new Date(t));
} }
else else
{ {
t = (this.format == 'Y-m-d' ? year + '-' + month + '-' + day : day + '.' + month + '.' + year) + t; t = (this.format == 'Y-m-d' ? year + '-' + month + '-' + day : day + '.' + month + '.' + year) + (t ? ' '+t : '');
i.value = t; i.value = t;
if ("Event" in window) if ("Event" in window)
{ {

1
calendar.min.js vendored

File diff suppressed because one or more lines are too long

View File

@ -9,14 +9,14 @@
"dependencies": {}, "dependencies": {},
"devDependencies": { "devDependencies": {
"babel-cli": "^6.26.0", "babel-cli": "^6.26.0",
"babel-core": "^6.26.0", "babel-core": "^6.26.3",
"babel-loader": "^7.1.4", "babel-loader": "^7.1.4",
"babel-preset-env": "^1.6.1", "babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1", "babel-preset-react": "^6.24.1",
"babel-preset-stage-1": "^6.24.1", "babel-preset-stage-1": "^6.24.1",
"preact": "^8.2.9", "preact": "^8.2.9",
"uglify-js": "^3.3.15", "uglify-js": "^3.4.9",
"webpack": "^4.14.0", "webpack": "^4.26.1",
"webpack-cli": "^3.0.8" "webpack-cli": "^3.0.8"
}, },
"scripts": { "scripts": {

View File

@ -13,7 +13,8 @@ module.exports = {
rules: [ rules: [
{ {
test: /.jsx?$/, test: /.jsx?$/,
loader: 'babel-loader' loader: 'babel-loader',
exclude: /node_modules/
} }
] ]
}, },