本文整理汇总了TypeScript中lodash.isDate函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isDate函数的具体用法?TypeScript isDate怎么用?TypeScript isDate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isDate函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: deepDiff
deepDiff(one: Object, two: Object, path: string = ''): IDeepDiff[] {
let result: IDeepDiff[] = [];
for (var key of _.keys(one)) {
let concatPath: string = path ? path + '.' + key : key;
if (_.isPlainObject(one[key])) {
if (!_.has(two, key)) {
result.push(new DeepDiff('deleted', concatPath, one[key], null));
} else {
result = _.concat(result, this.deepDiff(one[key], two[key], path ? path + '.' + key : key));
}
} else if (_.isBoolean(one[key]) || _.isDate(one[key]) || _.isNumber(one[key])
|| _.isNull(one[key]) || _.isRegExp(one[key]) || _.isString(one[key])) {
if (!_.has(two, key)) {
result.push(new DeepDiff('deleted', concatPath, one[key], null));
} else if (_.get(one, key) !== _.get(two, key)) {
result.push(new DeepDiff('edited', concatPath, one[key], two[key]));
}
} else if (_.isArray(one[key]) && _.isArray(two[key]) && !_.isEqual(one[key], two[key])) {
result.push(new DeepDiff('array', concatPath, one[key], two[key]));
} else if (!_.has(two, key)) {
result.push(new DeepDiff('deleted', concatPath, one[key], null));
}
}
for (var key of _.keys(two)) {
let concatPath: string = path ? path + '.' + key : key;
if (!_.has(one, key)) {
if (_.isPlainObject(two[key]) || _.isBoolean(two[key]) || _.isDate(two[key]) || _.isNumber(two[key])
|| _.isNull(two[key]) || _.isRegExp(two[key]) || _.isString(two[key]) || _.isArray(two[key])) {
result.push(new DeepDiff('created', concatPath, null, two[key]));
}
}
}
return result;
}
示例2: unsetIgnoredSubProperties
_.keys(one).forEach((key) => {
let concatPath: string = path ? path + '.' + key : key;
if (!_.includes(this.options.ignoreProperties, concatPath) && !_.includes(this.options.ignoreSubProperties, concatPath)) {
unsetIgnoredSubProperties(one[key]);
unsetIgnoredSubProperties(two[key]);
let getDeletedProperties = (obj: any, propPath: string = null) => {
if (_.isPlainObject(obj)) {
for (var objKey of _.keys(obj)) {
unsetIgnoredSubProperties(obj[objKey]);
getDeletedProperties(obj[objKey], propPath ? propPath + '.' + objKey : objKey);
}
} else if (_.isBoolean(obj) || _.isDate(obj) || _.isNumber(obj)
|| _.isNull(obj) || _.isRegExp(obj) || _.isString(obj) || _.isArray(obj)) {
result.push(new DeepDiff('deleted', propPath, obj, null));
}
};
if (_.isPlainObject(one[key])) {
if (!_.has(two, key)) {
getDeletedProperties(one[key], concatPath);
} else {
result = _.concat(result, this.deepDiff(one[key], two[key], path ? path + '.' + key : key));
}
} else if (_.isBoolean(one[key]) || _.isDate(one[key]) || _.isNumber(one[key])
|| _.isNull(one[key]) || _.isRegExp(one[key]) || _.isString(one[key])) {
if (!_.has(two, key)) {
result.push(new DeepDiff('deleted', concatPath, one[key], null));
} else if (_.isDate(one[key]) || _.isDate(two[key])) {
if (new Date(one[key]).valueOf() !== new Date(two[key]).valueOf()) {
result.push(new DeepDiff('edited', concatPath, new Date(one[key]), new Date(two[key])));
}
} else if (hash(one[key]) !== hash(two[key])) {
result.push(new DeepDiff('edited', concatPath, one[key], two[key]));
}
} else if (_.isArray(one[key]) && _.isArray(two[key]) && !_.isEqual(one[key], two[key])) {
for (var i = 0; i < one[key].length; i++) {
unsetIgnoredSubProperties(one[key][i]);
}
for (var i = 0; i < two[key].length; i++) {
unsetIgnoredSubProperties(two[key][i]);
}
if (hash(one[key]) !== hash(two[key])) {
result.push(new DeepDiff('array', concatPath, one[key], two[key]));
}
} else if (!_.has(two, key)) {
getDeletedProperties(one[key], concatPath);
}
}
});
示例3: parse
export function parse(text, roundUp?) {
if (!text) { return undefined; }
if (moment.isMoment(text)) { return text; }
if (_.isDate(text)) { return moment(text); }
var time;
var mathString = '';
var index;
var parseString;
if (text.substring(0, 3) === 'now') {
time = moment();
mathString = text.substring('now'.length);
} else {
index = text.indexOf('||');
if (index === -1) {
parseString = text;
mathString = ''; // nothing else
} else {
parseString = text.substring(0, index);
mathString = text.substring(index + 2);
}
// We're going to just require ISO8601 timestamps, k?
time = moment(parseString);
}
if (!mathString.length) {
return time;
}
return parseDateMath(mathString, time, roundUp);
}
示例4: function
format: function(date, mask) {
assert(_.isDate(date),
'DateFormatting.format: the first argument is required and has to be a JS Date instance');
assert(_.isString(mask),
'DateFormatting.format: the second argument is required and has to be a string representing the date format mask to represent date as');
return moment(date).format(mask);
},
示例5: it
it('works for the happy path', function() {
assert(_.isDate(date),
'parses the string given as the first argument according' +
' to the string mask passed in the second argument and returns a date object');
assert.equal(date.getDate(), 7, 'returned date has the appropriate date');
assert.equal(date.getMonth(), 5, 'returned date has the appropriate month');
assert.equal(date.getFullYear(), 2015, 'returned date has the appropriate year');
});
示例6: CompletionLabel
export function CompletionLabel(completionTime) {
assert(_.isDate(completionTime), 'CompletionLabel expects the completionTime argument to be a Date object');
var domElement = createElement();
WidgetRole.apply(this, [domElement]);
addContent(domElement, completionTime);
this.getData = delegateTo(completionTime, 'toISOString');
}
示例7: Date
app.get('/',(req,res)=>{
var q = req.query.q;
var ss = _.isDate(new Date());
console.log("ss:",ss);
var md5Value = utility.md5(q);
res.send(md5Value);
});
示例8:
val.forEach((v: any) => {
if (isObject(v)) {
if (isDate(v)) {
v = (v as Date).toISOString();
} else {
v = JSON.stringify(v);
}
}
parts.push(`${UrlBuilderUtils.encodeUriQuery(key)}=${UrlBuilderUtils.encodeUriQuery(v)}`);
});
示例9: it
it('takes two date for range.', () => {
const d1 = new Date(1999, 1, 1);
const d2 = new Date(2000, 3, 22);
const d3 = date.choose({ start: d1, end: d2 }).random;
const inRange = () => {
const t1 = d1.getTime();
const t2 = d2.getTime();
const t3 = d3.getTime();
return t1 <= t3 && t3 <= t2;
};
return isDate(d3) && inRange();
});