本文整理匯總了TypeScript中moment.Moment.format方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Moment.format方法的具體用法?TypeScript Moment.format怎麽用?TypeScript Moment.format使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類moment.Moment
的用法示例。
在下文中一共展示了Moment.format方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: emit_DATE
emit_DATE(value: Moment): string {
if (this.dialect === "mssql")
return "CONVERT(DATE,'" + value.format("YYYYMMDD") + "')";
else if (this.dialect === "postgres")
return "TIMESTAMP(3)'" + value.format("YYYY-MM-DD") + "'";
else if (this.dialect === "mysql")
// timezone не воспринимает
return "STR_TO_DATE('" + value.format("YYYY-MM-DD") + "','%Y-%c-%d')";
else {
let msg = "invalid sql dialect " + this.dialect;
throwError( msg + ", " + __filename);
throw "fake";
}
}
示例2: constructor
constructor(value: string | Moment) {
if (typeof value === 'string') {
if (!isValidDate(value)) {
throw new Error(`${value} isn't a valid ISO 8601 date literal`)
}
this.stringValue = value
} else {
this.stringValue = value.format(FORMAT)
}
}
示例3: postValidation
postValidation (req: express.Request, res: express.Response): FormValidationError {
const model = req.body.model
if (model.firstPaymentDate) {
const validDate: Moment = getEarliestPaymentDateForPaymentPlan(res.locals.claim, model.firstPaymentDate.toMoment())
if (validDate && validDate > model.firstPaymentDate.toMoment()) {
const error: ValidationError = {
target: model,
property: 'firstPaymentDate',
value: model.firstPaymentDate.toMoment(),
constraints: { 'Failed': 'Enter a date of ' + validDate.format('DD MM YYYY') + ' or later for the first instalment' },
children: undefined
}
return new FormValidationError(error)
}
}
return undefined
}
示例4: formatDate
static formatDate (value: Moment): string {
return value.format(DATE_FORMAT)
}
示例5: formatLongDateAndTime
static formatLongDateAndTime (value: Moment): string {
return `${MomentFormatter.formatLongDate(value)} at ${value.format(TIME_FORMAT)}`
}
示例6: formatLongDate
static formatLongDate (value: Moment): string {
return value.format(LONG_DATE_FORMAT)
}
示例7: formatInputDate
static formatInputDate (value: Moment): string {
return value.format(INPUT_DATE_FORMAT)
}
示例8: serializeDate
protected serializeDate(date :Moment) :string {
const formatter = this.getDateFormat();
return date.format(formatter);
}
示例9: format
public format(format: string): string {
const formatted = this.moment.format(format)
return formatted
}
示例10: it
it('should return "lll" moment format', () => {
expect(dateAdapter.fromMilliseconds(1523077200000)).toEqual(testMoment.format('lll'));
});