Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
moment.utc('2015-01-01', true);
moment.utc({ hour: 15, minute: 10 });
// $ExpectError only string values can have formatting parameters
moment.utc([2015, 0], "MM-DD-YYYY");
// $ExpectError
moment.utc([2015, 0], "MM-DD-YYYY", true);
// $ExpectError
moment.utc([2015, 0], moment.ISO_8601);
// $ExpectError
moment.utc({ hour: 15, minute: 10 }, "MM-DD-YYYY");
// Special formatting
moment.utc("2010-01-01T05:06:07", moment.ISO_8601);
moment.utc("2010-01-01T05:06:07", ["YYYY", moment.ISO_8601]);
moment.utc(new Date());
moment.utc(moment());
// null and undefined allowed as per moment TypeScript definitions
// https://github.com/moment/moment/blob/2.22.2/moment.d.ts#L400
// https://github.com/moment/moment/blob/2.22.2/moment.d.ts#L622
moment.utc(null);
moment.utc(undefined);
});
publicCryptox[method](options, function (err, result) {
expect(result).to.be.jsonSchema(schema.errorResult);
expect(moment(result.timestamp, moment.ISO_8601).isValid()).to.be.equal(true); // to be a valid ISO 8601 date
done();
});
});
// Got & adapted from from https://github.com/koopjs/FeatureServer/blob/master/src/utils.js
const moment = require('moment')
const DATE_FORMATS = [moment.ISO_8601]
function convertToEsriFields (obj) {
return Object.entries(obj).map(([key,value]) => getField(key,value));
}
function getField (k,v) {
return {
name: k,
type: esriTypeMap(detectType(v)),
alias: k,
nullable: true
}
}
function detectType (value) {
var type = typeof value
return backend.getStats().then(stats => {
if (!stats) {
throw new Error('There are no available stats for the remote door opening service');
}
const count = _.reduce(_.values(_.omit(stats, 'since')), (m, val) => m + val, 0);
const savedTime = Math.round(count * 40.0);
const savedTimeStr = moment.duration(savedTime, 'seconds').humanize();
const timeStr = moment(stats.since, moment.ISO_8601).fromNow();
const msg = `The remote door opening service was used ${count} time${count > 1 ? 's' : ''} since ${timeStr}.` +
`\nBreakdown by day:\n\`\`\`${histogram(_.omit(stats, 'since'), { sort: false })}\`\`\`` +
`\nAssuming that it takes ~40 seconds to open the door and get back, around ${savedTimeStr} have been saved!`;
bot[postMessageMethod](CHANNEL.name, msg, { as_user: 'true' });
}).catch(err => {
console.log(err);
it('renders properly', () => {
const timeIso = '2017-03-30T16:48:10';
const tDisplay = shallow();
const timeLong = moment.utc(timeIso, moment.ISO_8601).format('MMM D YYYY h:mm A z');
const timeRelative = moment.utc(timeIso, moment.ISO_8601).fromNow();
expect(tDisplay.html()).toBe(`<span title="${timeLong}">${timeRelative}</span>`);
});
});
.pipe(filter.obj(function(obj) { return obj.date && moment(obj.date, moment.ISO_8601).isValid(); }))
.pipe(sortStream(function(a, b) { return moment(a.date).diff(moment(b.date)); }))
private transform(item:Event) {
if (item.experienceLevel) {
this._levelService.getLevel(item.experienceLevel).then((level:Level)=> {
item.levelObject = level;
})
}
if (item.track) {
this._trackService.getTrack(item.track).then((track:Track)=> {
item.trackObject = track;
})
}
item.timeLabel = moment(item.from, moment.ISO_8601).format('ddd, LT') + ' - ' + moment(item.to, moment.ISO_8601).format('ddd, LT');
item.fromLabel = moment(item.from, moment.ISO_8601).format('LT');
item.toLabel = moment(item.to, moment.ISO_8601).format('LT');
item.href = false;
if (!this.isNonClickable(item.type)) {
item.href = true;
}
if (item.speakers) {
item.speakersCollection = [];
item.speakersNames = [];
item.speakers.forEach((speakerId) => {
this._speakerService.getSpeaker(speakerId).then((speaker:Speaker) => {
item.speakersCollection.push(speaker);
item.speakersNames.push(speaker.firstName + ' ' + speaker.lastName)
})
throw new Error('amount is required')
}
const amount = roundAmount(
new BigNumber(params.amount),
scale,
params.roundingMode || roundingMode
)
if (amount.decimalPlaces() > scale) {
throw new Error('request amount has more decimal places than the ledger supports (' + scale + ')')
}
if (amount.precision() > precision) {
throw new Error('request amount has more significant digits than the ledger supports (' + precision + ')')
}
if (params.expiresAt && !moment(params.expiresAt, moment.ISO_8601).isValid()) {
throw new Error('expiresAt must be an ISO 8601 timestamp')
}
const requestAddress = (params.account || account) + '.' + iprReceiverId + (params.id || uuid.v4())
const paymentRequest = {
address: requestAddress,
amount: amount.toString(),
expires_at: params.expiresAt || moment().add(defaultRequestTimeout, 'seconds').toISOString()
}
if (params.data) {
paymentRequest.data = params.data
}
const conditionPreimage = hmacHelper.hmacJsonForIprCondition(paymentRequest)
module.exports.DateTimeType = function(field, options) {
module.exports.JSType.call(this, field, options);
this.js = Object;
this.name = 'datetime';
this.formats = ['default', 'any', 'fmt'];
this.ISO8601 = moment.ISO_8601;
return this;
}
custom: (value) => _.isPlainObject(value)
&& _.size(value) === 2
&& (_.isNull(value.startedAt) || moment(value.startedAt, moment.ISO_8601, true).isValid())
&& _.isFinite(value.total),
},