本文整理汇总了TypeScript中luxon.DateTime.fromObject方法的典型用法代码示例。如果您正苦于以下问题:TypeScript DateTime.fromObject方法的具体用法?TypeScript DateTime.fromObject怎么用?TypeScript DateTime.fromObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类luxon.DateTime
的用法示例。
在下文中一共展示了DateTime.fromObject方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: arrayToLuxon
function arrayToLuxon(arr: number[], timeZone: string, locale?: string): LuxonDateTime {
return LuxonDateTime.fromObject({
zone: timeZone,
locale: locale,
year: arr[0],
month: arr[1] + 1, // convert 0-based to 1-based
day: arr[2],
hour: arr[3],
minute: arr[4],
second: arr[5],
millisecond: arr[6]
})
}
示例2:
import { DateTime, Duration, Interval, Info, Settings } from 'luxon';
/* DateTime */
const dt = DateTime.local(2017, 5, 15, 8, 30);
const now = DateTime.local();
const fromObject = DateTime.fromObject({
month: 4,
day: 22,
hour: 12,
zone: 'America/Los_Angeles',
numberingSystem: 'beng'
});
const fromIso = DateTime.fromISO('2017-05-15'); // => May 15, 2017 at midnight
const fromIso2 = DateTime.fromISO('2017-05-15T08:30:00'); // => May 15, 2017 at midnight
DateTime.local().toString(); // => '2017-09-14T03:20:34.091-04:00'
const getters = DateTime.local();
getters.year;
getters.month;
getters.day;
getters.second;
getters.weekday;
getters.zoneName;
getters.offset;
getters.daysInMonth;
getters.ordinal;