本文整理汇总了TypeScript中moment类的典型用法代码示例。如果您正苦于以下问题:TypeScript moment类的具体用法?TypeScript moment怎么用?TypeScript moment使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了moment类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should update the date to one month ago', () => {
datepicker.open();
let oneMonthAgo = moment().subtract(1, 'months').format(isoFormat);
datepicker.date = oneMonthAgo;
expect(datepicker.date).to.eventually.eql(oneMonthAgo);
});
示例2: it
it('should initialize properly', () => {
expect(moment().isSame(dp.now, 'day')).toBeTruthy();
expect(dp._baseMonth).toEqual(moment().month());
expect(dp.hideComponent).toBe(true);
});
示例3: transform
transform(value: string, formatFrom: string, formatTo: string = 'DD.MM.YYYY'): string {
return moment(value, formatFrom).format(formatTo);
}
示例4: getMoment
function getMoment(culture: string, value: any, format: string | undefined) {
return culture ? localField(moment(value, format))(culture) : moment(value, format);
}
示例5: function
m.smartNow = function () { return moment(); };
示例6: transform
transform(value: number, args: string[]) : any {
var date = moment(value).locale('de').fromNow()+' : '+moment(value).locale('de').format('dddd, Do MMMM ');
return date;
}
示例7: format
function format(value: string | Date, format='YYYY-MM-DD HH:mm'): string {
return moment(value).format(format);
}
示例8: getResults
public async getResults(id: number, dateFrom?: Date, dateTo?: Date) {
return await this.httpClient.get<ICheckResults>("/api/results/" + id.toString()
+ (typeof dateFrom !== "undefined" ? "/" + moment(dateFrom).format("YYYY-MM-DD") : "")
+ (typeof dateTo !== "undefined" ? "/" + moment(dateTo).format("YYYY-MM-DD") : "")).pipe(first()).toPromise();
}
示例9: moment
@Transform(value => moment(value), { since: 1, until: 2 })
示例10: getConnection
return getConnection().then(connection => {
ApplicationModel.setConnection(connection);
ApplicationBasicinfoModel.setConnection(connection);
let beforeId, afterId;
return new ApplicationModel({
agencyCode: 'agencyCode',
cscId: 'cscId',
applyType: 'applyType',
type: 'type',
submitType: 'st',
dispacth: 'dispacth',
dispacthProject: 'dp',
projectAttr: 'pa',
projectType: 'pt',
projectName: 'pn',
candidateType: 'candidateType',
remark1: 'remark1',
remark2: 'remark2',
remark3: 'remark3',
remark4: 'remark4',
status: 'status',
statusUpdateAt: m(),
createBy: 'createBy',
createAt: m(),
updateBy: 'updateBy',
updateAt: m()
}).save().then(_application => {
let id = _application.id;
beforeId = _application.id;
return new ApplicationBasicinfoModel({
id,
firstname: 'firstname',
lastname: 'lastname',
fullname: 'f l',
chineseName: 'chineseName',
gender: 'gender',
birthday: m(),
maritalStatus: 'maritalStatus',
nationality: 'n',
passportCode: 'passportCode',
nativeLanguage: 'nl',
religion: 'religion',
birthCountry: 'birthCountry',
birthCity: 'birthCity',
permanentTel: 'permanentTel',
permanentFax: 'permanentFax',
permanentEmail: 'permanentEmail',
permanentAddress: 'permanentAddress',
presentTel: 'presentTel',
presentFax: 'presentFax',
presentEmail: 'presentEmail',
presentAddress: 'presentAddress',
passportDeadline: m(),
}).save();
// _application.cscId = 'CSCiD';
// return _application.save();
}).then(_basicinfo => {
_basicinfo.gender = 'GENdER';
return _basicinfo.save();
}).then(_basicinfo => {
afterId = _basicinfo.id;
assert(_basicinfo.gender, 'GENdER');
assert.equal(beforeId, afterId);
return connection;
});
}).then(connection => connection.release());