empty master
This commit is contained in:
parent
92c1162255
commit
67d534df27
276 changed files with 0 additions and 28368 deletions
|
@ -1,168 +0,0 @@
|
|||
// 判断参数是否是其中之一
|
||||
export function oneOf (value, validList) {
|
||||
for (let i = 0; i < validList.length; i++) {
|
||||
if (value === validList[i]) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
export function camelcaseToHyphen (str) {
|
||||
return str.replace(/([a-z])([A-Z])/g, '$1-$2').toLowerCase();
|
||||
}
|
||||
|
||||
// For Modal scrollBar hidden
|
||||
let cached;
|
||||
export function getScrollBarSize (fresh) {
|
||||
if (fresh || cached === undefined) {
|
||||
const inner = document.createElement('div');
|
||||
inner.style.width = '100%';
|
||||
inner.style.height = '200px';
|
||||
|
||||
const outer = document.createElement('div');
|
||||
const outerStyle = outer.style;
|
||||
|
||||
outerStyle.position = 'absolute';
|
||||
outerStyle.top = 0;
|
||||
outerStyle.left = 0;
|
||||
outerStyle.pointerEvents = 'none';
|
||||
outerStyle.visibility = 'hidden';
|
||||
outerStyle.width = '200px';
|
||||
outerStyle.height = '150px';
|
||||
outerStyle.overflow = 'hidden';
|
||||
|
||||
outer.appendChild(inner);
|
||||
|
||||
document.body.appendChild(outer);
|
||||
|
||||
const widthContained = inner.offsetWidth;
|
||||
outer.style.overflow = 'scroll';
|
||||
let widthScroll = inner.offsetWidth;
|
||||
|
||||
if (widthContained === widthScroll) {
|
||||
widthScroll = outer.clientWidth;
|
||||
}
|
||||
|
||||
document.body.removeChild(outer);
|
||||
|
||||
cached = widthContained - widthScroll;
|
||||
}
|
||||
return cached;
|
||||
}
|
||||
|
||||
// watch DOM change
|
||||
export const MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver || false;
|
||||
|
||||
const SPECIAL_CHARS_REGEXP = /([\:\-\_]+(.))/g;
|
||||
const MOZ_HACK_REGEXP = /^moz([A-Z])/;
|
||||
|
||||
function camelCase(name) {
|
||||
return name.replace(SPECIAL_CHARS_REGEXP, function(_, separator, letter, offset) {
|
||||
return offset ? letter.toUpperCase() : letter;
|
||||
}).replace(MOZ_HACK_REGEXP, 'Moz$1');
|
||||
}
|
||||
// getStyle
|
||||
export function getStyle (element, styleName) {
|
||||
if (!element || !styleName) return null;
|
||||
styleName = camelCase(styleName);
|
||||
if (styleName === 'float') {
|
||||
styleName = 'cssFloat';
|
||||
}
|
||||
try {
|
||||
const computed = document.defaultView.getComputedStyle(element, '');
|
||||
return element.style[styleName] || computed ? computed[styleName] : null;
|
||||
} catch(e) {
|
||||
return element.style[styleName];
|
||||
}
|
||||
}
|
||||
|
||||
// firstUpperCase
|
||||
function firstUpperCase(str) {
|
||||
return str.toString()[0].toUpperCase() + str.toString().slice(1);
|
||||
}
|
||||
export {firstUpperCase};
|
||||
|
||||
// Warn
|
||||
export function warnProp(component, prop, correctType, wrongType) {
|
||||
correctType = firstUpperCase(correctType);
|
||||
wrongType = firstUpperCase(wrongType);
|
||||
console.error(`[iView warn]: Invalid prop: type check failed for prop ${prop}. Expected ${correctType}, got ${wrongType}. (found in component: ${component})`); // eslint-disable-line
|
||||
}
|
||||
|
||||
function typeOf(obj) {
|
||||
const toString = Object.prototype.toString;
|
||||
const map = {
|
||||
'[object Boolean]' : 'boolean',
|
||||
'[object Number]' : 'number',
|
||||
'[object String]' : 'string',
|
||||
'[object Function]' : 'function',
|
||||
'[object Array]' : 'array',
|
||||
'[object Date]' : 'date',
|
||||
'[object RegExp]' : 'regExp',
|
||||
'[object Undefined]': 'undefined',
|
||||
'[object Null]' : 'null',
|
||||
'[object Object]' : 'object'
|
||||
};
|
||||
return map[toString.call(obj)];
|
||||
}
|
||||
|
||||
// deepCopy
|
||||
function deepCopy(data) {
|
||||
const t = typeOf(data);
|
||||
let o;
|
||||
|
||||
if (t === 'array') {
|
||||
o = [];
|
||||
} else if ( t === 'object') {
|
||||
o = {};
|
||||
} else {
|
||||
return data;
|
||||
}
|
||||
|
||||
if (t === 'array') {
|
||||
for (let i = 0; i < data.length; i++) {
|
||||
o.push(deepCopy(data[i]));
|
||||
}
|
||||
} else if ( t === 'object') {
|
||||
for (let i in data) {
|
||||
o[i] = deepCopy(data[i]);
|
||||
}
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
||||
export {deepCopy};
|
||||
|
||||
// scrollTop animation
|
||||
export function scrollTop(el, from = 0, to, duration = 500) {
|
||||
if (!window.requestAnimationFrame) {
|
||||
window.requestAnimationFrame = (
|
||||
window.webkitRequestAnimationFrame ||
|
||||
window.mozRequestAnimationFrame ||
|
||||
window.msRequestAnimationFrame ||
|
||||
function (callback) {
|
||||
return window.setTimeout(callback, 1000/60);
|
||||
}
|
||||
);
|
||||
}
|
||||
const difference = Math.abs(from - to);
|
||||
const step = Math.ceil(difference / duration * 50);
|
||||
|
||||
function scroll(start, end, step) {
|
||||
if (start === end) return;
|
||||
|
||||
let d = (start + step > end) ? end : start + step;
|
||||
if (start > end) {
|
||||
d = (start - step < end) ? end : start - step;
|
||||
}
|
||||
|
||||
if (el === window) {
|
||||
window.scrollTo(d, d);
|
||||
} else {
|
||||
el.scrollTop = d;
|
||||
}
|
||||
window.requestAnimationFrame(() => scroll(d, end, step));
|
||||
}
|
||||
scroll(from, to, step);
|
||||
}
|
|
@ -1,108 +0,0 @@
|
|||
// Thanks to
|
||||
// https://github.com/andreypopp/react-textarea-autosize/
|
||||
// https://github.com/ElemeFE/element/blob/master/packages/input/src/calcTextareaHeight.js
|
||||
|
||||
let hiddenTextarea;
|
||||
|
||||
const HIDDEN_STYLE = `
|
||||
height:0 !important;
|
||||
min-height:0 !important;
|
||||
max-height:none !important;
|
||||
visibility:hidden !important;
|
||||
overflow:hidden !important;
|
||||
position:absolute !important;
|
||||
z-index:-1000 !important;
|
||||
top:0 !important;
|
||||
right:0 !important
|
||||
`;
|
||||
|
||||
const CONTEXT_STYLE = [
|
||||
'letter-spacing',
|
||||
'line-height',
|
||||
'padding-top',
|
||||
'padding-bottom',
|
||||
'font-family',
|
||||
'font-weight',
|
||||
'font-size',
|
||||
'text-rendering',
|
||||
'text-transform',
|
||||
'width',
|
||||
'text-indent',
|
||||
'padding-left',
|
||||
'padding-right',
|
||||
'border-width',
|
||||
'box-sizing'
|
||||
];
|
||||
|
||||
function calculateNodeStyling(node) {
|
||||
const style = window.getComputedStyle(node);
|
||||
|
||||
const boxSizing = style.getPropertyValue('box-sizing');
|
||||
|
||||
const paddingSize = (
|
||||
parseFloat(style.getPropertyValue('padding-bottom')) +
|
||||
parseFloat(style.getPropertyValue('padding-top'))
|
||||
);
|
||||
|
||||
const borderSize = (
|
||||
parseFloat(style.getPropertyValue('border-bottom-width')) +
|
||||
parseFloat(style.getPropertyValue('border-top-width'))
|
||||
);
|
||||
|
||||
const contextStyle = CONTEXT_STYLE
|
||||
.map(name => `${name}:${style.getPropertyValue(name)}`)
|
||||
.join(';');
|
||||
|
||||
return {contextStyle, paddingSize, borderSize, boxSizing};
|
||||
}
|
||||
|
||||
export default function calcTextareaHeight(targetNode, minRows = null, maxRows = null) {
|
||||
if (!hiddenTextarea) {
|
||||
hiddenTextarea = document.createElement('textarea');
|
||||
document.body.appendChild(hiddenTextarea);
|
||||
}
|
||||
|
||||
let {
|
||||
paddingSize,
|
||||
borderSize,
|
||||
boxSizing,
|
||||
contextStyle
|
||||
} = calculateNodeStyling(targetNode);
|
||||
|
||||
hiddenTextarea.setAttribute('style', `${contextStyle};${HIDDEN_STYLE}`);
|
||||
hiddenTextarea.value = targetNode.value || targetNode.placeholder || '';
|
||||
|
||||
let height = hiddenTextarea.scrollHeight;
|
||||
let minHeight = -Infinity;
|
||||
let maxHeight = Infinity;
|
||||
|
||||
if (boxSizing === 'border-box') {
|
||||
height = height + borderSize;
|
||||
} else if (boxSizing === 'content-box') {
|
||||
height = height - paddingSize;
|
||||
}
|
||||
|
||||
hiddenTextarea.value = '';
|
||||
let singleRowHeight = hiddenTextarea.scrollHeight - paddingSize;
|
||||
|
||||
if (minRows !== null) {
|
||||
minHeight = singleRowHeight * minRows;
|
||||
if (boxSizing === 'border-box') {
|
||||
minHeight = minHeight + paddingSize + borderSize;
|
||||
}
|
||||
height = Math.max(minHeight, height);
|
||||
}
|
||||
if (maxRows !== null) {
|
||||
maxHeight = singleRowHeight * maxRows;
|
||||
if (boxSizing === 'border-box') {
|
||||
maxHeight = maxHeight + paddingSize + borderSize;
|
||||
}
|
||||
height = Math.min(maxHeight, height);
|
||||
}
|
||||
|
||||
return {
|
||||
height: `${height}px`,
|
||||
minHeight: `${minHeight}px`,
|
||||
maxHeight: `${maxHeight}px`
|
||||
};
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
// https://github.com/Terminux/react-csv-downloader/blob/master/src/lib/csv.js
|
||||
|
||||
const newLine = '\r\n';
|
||||
|
||||
export default function csv(columns, datas, separator = ',', noHeader = false) {
|
||||
let columnOrder;
|
||||
const content = [];
|
||||
const column = [];
|
||||
|
||||
if (columns) {
|
||||
columnOrder = columns.map(v => {
|
||||
if (typeof v === 'string') {
|
||||
return v;
|
||||
}
|
||||
if (!noHeader) {
|
||||
column.push((typeof v.title !== 'undefined') ? v.title : v.key);
|
||||
}
|
||||
return v.key;
|
||||
});
|
||||
if (column.length > 0) {
|
||||
content.push(column.join(separator));
|
||||
}
|
||||
} else {
|
||||
columnOrder = [];
|
||||
datas.forEach(v => {
|
||||
if (!Array.isArray(v)) {
|
||||
columnOrder = columnOrder.concat(Object.keys(v));
|
||||
}
|
||||
});
|
||||
if (columnOrder.length > 0) {
|
||||
columnOrder = columnOrder.filter((value, index, self) => self.indexOf(value) === index);
|
||||
|
||||
if (!noHeader) {
|
||||
content.push(columnOrder.join(separator));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (Array.isArray(datas)) {
|
||||
datas.map(v => {
|
||||
if (Array.isArray(v)) {
|
||||
return v;
|
||||
}
|
||||
return columnOrder.map(k => {
|
||||
if (typeof v[k] !== 'undefined') {
|
||||
return v[k];
|
||||
}
|
||||
return '';
|
||||
});
|
||||
}).forEach(v => {
|
||||
content.push(v.join(separator));
|
||||
});
|
||||
}
|
||||
return content.join(newLine);
|
||||
}
|
|
@ -1,319 +0,0 @@
|
|||
/*eslint-disable*/
|
||||
// 把 YYYY-MM-DD 改成了 yyyy-MM-dd
|
||||
(function (main) {
|
||||
'use strict';
|
||||
|
||||
/**
|
||||
* Parse or format dates
|
||||
* @class fecha
|
||||
*/
|
||||
var fecha = {};
|
||||
var token = /d{1,4}|M{1,4}|yy(?:yy)?|S{1,3}|Do|ZZ|([HhMsDm])\1?|[aA]|"[^"]*"|'[^']*'/g;
|
||||
var twoDigits = /\d\d?/;
|
||||
var threeDigits = /\d{3}/;
|
||||
var fourDigits = /\d{4}/;
|
||||
var word = /[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i;
|
||||
var noop = function () {
|
||||
};
|
||||
|
||||
function shorten(arr, sLen) {
|
||||
var newArr = [];
|
||||
for (var i = 0, len = arr.length; i < len; i++) {
|
||||
newArr.push(arr[i].substr(0, sLen));
|
||||
}
|
||||
return newArr;
|
||||
}
|
||||
|
||||
function monthUpdate(arrName) {
|
||||
return function (d, v, i18n) {
|
||||
var index = i18n[arrName].indexOf(v.charAt(0).toUpperCase() + v.substr(1).toLowerCase());
|
||||
if (~index) {
|
||||
d.month = index;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function pad(val, len) {
|
||||
val = String(val);
|
||||
len = len || 2;
|
||||
while (val.length < len) {
|
||||
val = '0' + val;
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
var dayNames = ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'];
|
||||
var monthNames = ['January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December'];
|
||||
var monthNamesShort = shorten(monthNames, 3);
|
||||
var dayNamesShort = shorten(dayNames, 3);
|
||||
fecha.i18n = {
|
||||
dayNamesShort: dayNamesShort,
|
||||
dayNames: dayNames,
|
||||
monthNamesShort: monthNamesShort,
|
||||
monthNames: monthNames,
|
||||
amPm: ['am', 'pm'],
|
||||
DoFn: function DoFn(D) {
|
||||
return D + ['th', 'st', 'nd', 'rd'][D % 10 > 3 ? 0 : (D - D % 10 !== 10) * D % 10];
|
||||
}
|
||||
};
|
||||
|
||||
var formatFlags = {
|
||||
D: function (dateObj) {
|
||||
return dateObj.getDay();
|
||||
},
|
||||
DD: function (dateObj) {
|
||||
return pad(dateObj.getDay());
|
||||
},
|
||||
Do: function (dateObj, i18n) {
|
||||
return i18n.DoFn(dateObj.getDate());
|
||||
},
|
||||
d: function (dateObj) {
|
||||
return dateObj.getDate();
|
||||
},
|
||||
dd: function (dateObj) {
|
||||
return pad(dateObj.getDate());
|
||||
},
|
||||
ddd: function (dateObj, i18n) {
|
||||
return i18n.dayNamesShort[dateObj.getDay()];
|
||||
},
|
||||
dddd: function (dateObj, i18n) {
|
||||
return i18n.dayNames[dateObj.getDay()];
|
||||
},
|
||||
M: function (dateObj) {
|
||||
return dateObj.getMonth() + 1;
|
||||
},
|
||||
MM: function (dateObj) {
|
||||
return pad(dateObj.getMonth() + 1);
|
||||
},
|
||||
MMM: function (dateObj, i18n) {
|
||||
return i18n.monthNamesShort[dateObj.getMonth()];
|
||||
},
|
||||
MMMM: function (dateObj, i18n) {
|
||||
return i18n.monthNames[dateObj.getMonth()];
|
||||
},
|
||||
yy: function (dateObj) {
|
||||
return String(dateObj.getFullYear()).substr(2);
|
||||
},
|
||||
yyyy: function (dateObj) {
|
||||
return dateObj.getFullYear();
|
||||
},
|
||||
h: function (dateObj) {
|
||||
return dateObj.getHours() % 12 || 12;
|
||||
},
|
||||
hh: function (dateObj) {
|
||||
return pad(dateObj.getHours() % 12 || 12);
|
||||
},
|
||||
H: function (dateObj) {
|
||||
return dateObj.getHours();
|
||||
},
|
||||
HH: function (dateObj) {
|
||||
return pad(dateObj.getHours());
|
||||
},
|
||||
m: function (dateObj) {
|
||||
return dateObj.getMinutes();
|
||||
},
|
||||
mm: function (dateObj) {
|
||||
return pad(dateObj.getMinutes());
|
||||
},
|
||||
s: function (dateObj) {
|
||||
return dateObj.getSeconds();
|
||||
},
|
||||
ss: function (dateObj) {
|
||||
return pad(dateObj.getSeconds());
|
||||
},
|
||||
S: function (dateObj) {
|
||||
return Math.round(dateObj.getMilliseconds() / 100);
|
||||
},
|
||||
SS: function (dateObj) {
|
||||
return pad(Math.round(dateObj.getMilliseconds() / 10), 2);
|
||||
},
|
||||
SSS: function (dateObj) {
|
||||
return pad(dateObj.getMilliseconds(), 3);
|
||||
},
|
||||
a: function (dateObj, i18n) {
|
||||
return dateObj.getHours() < 12 ? i18n.amPm[0] : i18n.amPm[1];
|
||||
},
|
||||
A: function (dateObj, i18n) {
|
||||
return dateObj.getHours() < 12 ? i18n.amPm[0].toUpperCase() : i18n.amPm[1].toUpperCase();
|
||||
},
|
||||
ZZ: function (dateObj) {
|
||||
var o = dateObj.getTimezoneOffset();
|
||||
return (o > 0 ? '-' : '+') + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4);
|
||||
}
|
||||
};
|
||||
|
||||
var parseFlags = {
|
||||
d: [twoDigits, function (d, v) {
|
||||
d.day = v;
|
||||
}],
|
||||
M: [twoDigits, function (d, v) {
|
||||
d.month = v - 1;
|
||||
}],
|
||||
yy: [twoDigits, function (d, v) {
|
||||
var da = new Date(), cent = +('' + da.getFullYear()).substr(0, 2);
|
||||
d.year = '' + (v > 68 ? cent - 1 : cent) + v;
|
||||
}],
|
||||
h: [twoDigits, function (d, v) {
|
||||
d.hour = v;
|
||||
}],
|
||||
m: [twoDigits, function (d, v) {
|
||||
d.minute = v;
|
||||
}],
|
||||
s: [twoDigits, function (d, v) {
|
||||
d.second = v;
|
||||
}],
|
||||
yyyy: [fourDigits, function (d, v) {
|
||||
d.year = v;
|
||||
}],
|
||||
S: [/\d/, function (d, v) {
|
||||
d.millisecond = v * 100;
|
||||
}],
|
||||
SS: [/\d{2}/, function (d, v) {
|
||||
d.millisecond = v * 10;
|
||||
}],
|
||||
SSS: [threeDigits, function (d, v) {
|
||||
d.millisecond = v;
|
||||
}],
|
||||
D: [twoDigits, noop],
|
||||
ddd: [word, noop],
|
||||
MMM: [word, monthUpdate('monthNamesShort')],
|
||||
MMMM: [word, monthUpdate('monthNames')],
|
||||
a: [word, function (d, v, i18n) {
|
||||
var val = v.toLowerCase();
|
||||
if (val === i18n.amPm[0]) {
|
||||
d.isPm = false;
|
||||
} else if (val === i18n.amPm[1]) {
|
||||
d.isPm = true;
|
||||
}
|
||||
}],
|
||||
ZZ: [/[\+\-]\d\d:?\d\d/, function (d, v) {
|
||||
var parts = (v + '').match(/([\+\-]|\d\d)/gi), minutes;
|
||||
|
||||
if (parts) {
|
||||
minutes = +(parts[1] * 60) + parseInt(parts[2], 10);
|
||||
d.timezoneOffset = parts[0] === '+' ? minutes : -minutes;
|
||||
}
|
||||
}]
|
||||
};
|
||||
parseFlags.DD = parseFlags.DD;
|
||||
parseFlags.dddd = parseFlags.ddd;
|
||||
parseFlags.Do = parseFlags.dd = parseFlags.d;
|
||||
parseFlags.mm = parseFlags.m;
|
||||
parseFlags.hh = parseFlags.H = parseFlags.HH = parseFlags.h;
|
||||
parseFlags.MM = parseFlags.M;
|
||||
parseFlags.ss = parseFlags.s;
|
||||
parseFlags.A = parseFlags.a;
|
||||
|
||||
|
||||
// Some common format strings
|
||||
fecha.masks = {
|
||||
'default': 'ddd MMM dd yyyy HH:mm:ss',
|
||||
shortDate: 'M/D/yy',
|
||||
mediumDate: 'MMM d, yyyy',
|
||||
longDate: 'MMMM d, yyyy',
|
||||
fullDate: 'dddd, MMMM d, yyyy',
|
||||
shortTime: 'HH:mm',
|
||||
mediumTime: 'HH:mm:ss',
|
||||
longTime: 'HH:mm:ss.SSS'
|
||||
};
|
||||
|
||||
/***
|
||||
* Format a date
|
||||
* @method format
|
||||
* @param {Date|number} dateObj
|
||||
* @param {string} mask Format of the date, i.e. 'mm-dd-yy' or 'shortDate'
|
||||
*/
|
||||
fecha.format = function (dateObj, mask, i18nSettings) {
|
||||
var i18n = i18nSettings || fecha.i18n;
|
||||
|
||||
if (typeof dateObj === 'number') {
|
||||
dateObj = new Date(dateObj);
|
||||
}
|
||||
|
||||
if (Object.prototype.toString.call(dateObj) !== '[object Date]' || isNaN(dateObj.getTime())) {
|
||||
throw new Error('Invalid Date in fecha.format');
|
||||
}
|
||||
|
||||
mask = fecha.masks[mask] || mask || fecha.masks['default'];
|
||||
|
||||
return mask.replace(token, function ($0) {
|
||||
return $0 in formatFlags ? formatFlags[$0](dateObj, i18n) : $0.slice(1, $0.length - 1);
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse a date string into an object, changes - into /
|
||||
* @method parse
|
||||
* @param {string} dateStr Date string
|
||||
* @param {string} format Date parse format
|
||||
* @returns {Date|boolean}
|
||||
*/
|
||||
fecha.parse = function (dateStr, format, i18nSettings) {
|
||||
var i18n = i18nSettings || fecha.i18n;
|
||||
|
||||
if (typeof format !== 'string') {
|
||||
throw new Error('Invalid format in fecha.parse');
|
||||
}
|
||||
|
||||
format = fecha.masks[format] || format;
|
||||
|
||||
// Avoid regular expression denial of service, fail early for really long strings
|
||||
// https://www.owasp.org/index.php/Regular_expression_Denial_of_Service_-_ReDoS
|
||||
if (dateStr.length > 1000) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var isValid = true;
|
||||
var dateInfo = {};
|
||||
format.replace(token, function ($0) {
|
||||
if (parseFlags[$0]) {
|
||||
var info = parseFlags[$0];
|
||||
var index = dateStr.search(info[0]);
|
||||
if (!~index) {
|
||||
isValid = false;
|
||||
} else {
|
||||
dateStr.replace(info[0], function (result) {
|
||||
info[1](dateInfo, result, i18n);
|
||||
dateStr = dateStr.substr(index + result.length);
|
||||
return result;
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return parseFlags[$0] ? '' : $0.slice(1, $0.length - 1);
|
||||
});
|
||||
|
||||
if (!isValid) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var today = new Date();
|
||||
if (dateInfo.isPm === true && dateInfo.hour != null && +dateInfo.hour !== 12) {
|
||||
dateInfo.hour = +dateInfo.hour + 12;
|
||||
} else if (dateInfo.isPm === false && +dateInfo.hour === 12) {
|
||||
dateInfo.hour = 0;
|
||||
}
|
||||
|
||||
var date;
|
||||
if (dateInfo.timezoneOffset != null) {
|
||||
dateInfo.minute = +(dateInfo.minute || 0) - +dateInfo.timezoneOffset;
|
||||
date = new Date(Date.UTC(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
|
||||
dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0));
|
||||
} else {
|
||||
date = new Date(dateInfo.year || today.getFullYear(), dateInfo.month || 0, dateInfo.day || 1,
|
||||
dateInfo.hour || 0, dateInfo.minute || 0, dateInfo.second || 0, dateInfo.millisecond || 0);
|
||||
}
|
||||
return date;
|
||||
};
|
||||
|
||||
/* istanbul ignore next */
|
||||
if (typeof module !== 'undefined' && module.exports) {
|
||||
module.exports = fecha;
|
||||
} else if (typeof define === 'function' && define.amd) {
|
||||
define(function () {
|
||||
return fecha;
|
||||
});
|
||||
} else {
|
||||
main.fecha = fecha;
|
||||
}
|
||||
})(this);
|
Loading…
Add table
Add a link
Reference in a new issue