本文整理匯總了TypeScript中luxon.DateTime.local方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript DateTime.local方法的具體用法?TypeScript DateTime.local怎麽用?TypeScript DateTime.local使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類luxon.DateTime
的用法示例。
在下文中一共展示了DateTime.local方法的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('generates correcty zoned recurrences when a tzid is present', () => {
const targetZone = 'America/New_York'
const currentLocalDate = DateTime.local(2000, 2, 6, 11, 0, 0)
setMockDate(currentLocalDate.toJSDate())
const set = new RRuleSet()
set.rrule(new RRule({
freq: RRule.YEARLY,
count: 4,
dtstart: DateTime.fromISO('20000101T090000').toJSDate(),
tzid: targetZone
}))
set.exdate(
DateTime.fromISO('20010101T090000').toJSDate(),
)
set.rdate(
DateTime.fromISO('20020301T090000').toJSDate(),
)
expect(set.all()).to.deep.equal([
expectedDate(DateTime.fromISO('20000101T090000'), currentLocalDate, targetZone),
expectedDate(DateTime.fromISO('20020101T090000'), currentLocalDate, targetZone),
expectedDate(DateTime.fromISO('20020301T090000'), currentLocalDate, targetZone),
expectedDate(DateTime.fromISO('20030101T090000'), currentLocalDate, targetZone),
])
resetMockDate()
})
示例2: it
it('returns the date in the correct zone when given', () => {
const targetZone = 'America/New_York'
const currentLocalDate = DateTime.local(2000, 2, 6, 1, 0, 0)
setMockDate(currentLocalDate.toJSDate())
const d = DateTime.fromISO('20101005T110000').toJSDate()
const dt = new DateWithZone(d, targetZone)
expect(dt.rezonedDate()).to.deep.equal(
expectedDate(DateTime.fromISO('20101005T110000'), currentLocalDate, targetZone)
)
resetMockDate()
})
示例3: test
test('folding with noTradePeriods', async () => {
configStore.config.iterationInterval = 10;
const current = DateTime.local();
const start = current.minus({ minutes: 5 });
const end = current.plus({ minutes: 5 });
configStore.config.brokers[0].noTradePeriods = [
[start.toLocaleString(DateTime.TIME_24_SIMPLE), end.toLocaleString(DateTime.TIME_24_SIMPLE)]
];
const bitflyerBa = {
broker: 'Bitflyer',
fetchQuotes: () =>
Promise.resolve([
{ broker: 'Bitflyer', side: QuoteSide.Ask, price: 500000, volume: 0.1 },
{ broker: 'Bitflyer', side: QuoteSide.Ask, price: 500001, volume: 0.1 }
])
};
const coincheckBa = {
broker: 'Coincheck',
fetchQuotes: () =>
Promise.resolve([
{ broker: 'Coincheck', side: QuoteSide.Bid, price: 490001, volume: 0.02 },
{ broker: 'Coincheck', side: QuoteSide.Bid, price: 490000, volume: 0.2 }
])
};
const quoineBa = {
broker: 'Quoine',
fetchQuotes: () => Promise.resolve([])
};
const baList = [bitflyerBa, coincheckBa, quoineBa];
const baRouter = new BrokerAdapterRouter(baList);
const aggregator: QuoteAggregator = new QuoteAggregator(configStore, baRouter);
const mustBeCalled = jest.fn();
aggregator.onQuoteUpdated.set('Arbitrager', async quotes => {
expect(quotes.length).toBe(1);
mustBeCalled();
});
await aggregator.start();
await delay(0);
await aggregator.stop();
expect(mustBeCalled.mock.calls.length).toBeGreaterThanOrEqual(1);
});
示例4: ngOnInit
ngOnInit() {
this.users = sortBy<UserModel>(this.route.snapshot.data.users, user => user.login);
// If no param, default to the current month
const paramMap = this.route.snapshot.queryParamMap;
if (!paramMap.get('from') && !paramMap.get('to') && !paramMap.get('by')) {
const now = DateTime.local();
this.criteriaForm.setValue( {
from: now.startOf('month').toISODate(),
to: now.endOf('month').toISODate(),
by: ALL_USERS
});
} else {
this.criteriaForm.setValue( {
from: paramMap.get('from'),
to: paramMap.get('to'),
by: +paramMap.get('by')
});
}
// when criteria change, we update the URL
// when from or to changes, we reload the statistics
concat(of(this.criteriaForm.value), this.criteriaForm.valueChanges).pipe(
filter(() => this.criteriaForm.valid),
tap(value => this.router.navigate(['tasks/statistics'], { queryParams: value, replaceUrl: true })),
map(value => ({ from: value.from, to: value.to })),
distinctUntilChanged((v1, v2) => v1.from === v2.from && v1.to === v2.to),
switchMap(value => this.taskService.spentTimeStatistics(value)
.pipe(catchError(() => EMPTY)))
).subscribe(stats => this.updateState(stats));
// when by changes, no need to reload the statistics, but the chart must be updated
// note: using the valueChanges on the "by" form control doesn't change because the event is emitted before
// the value of the form group is updated
this.criteriaForm.valueChanges.pipe(
map(value => value.by),
distinctUntilChanged()
).subscribe(() => this.updateState(this.statisticsModel));
}
示例5: configure
public async configure(options: MediaConfigureOptions) {
const devicePayload = this.client.state.devicePayload;
const now = DateTime.local().toFormat('yyyy:mm:dd HH:mm:ss');
const width = options.width || 1520;
const height = options.height || 2048;
const form = defaultsDeep(options, {
date_time_digitalized: now,
camera_model: devicePayload.model,
scene_capture_type: 'standard',
timezone_offset: this.client.state.timezoneOffset,
_csrftoken: this.client.state.cookieCsrfToken,
media_folder: 'Camera',
source_type: '4',
_uid: this.client.state.cookieAccountId,
device_id: this.client.state.deviceId,
_uuid: this.client.state.uuid,
creation_logger_session_id: this.client.state.clientSessionId,
caption: '',
date_time_original: now,
software: '1',
camera_make: devicePayload.manufacturer,
device: devicePayload,
edits: {
crop_original_size: [width, height],
crop_center: [0.0, -0.0],
crop_zoom: random(1.01, 1.99).toFixed(7),
},
extra: { source_width: width, source_height: height },
});
this.client.request.send({
url: '/api/v1/media/configure/',
method: 'POST',
form: this.client.request.sign(form),
});
}
示例6: listUrgent
listUrgent(pageNumber: number): Observable<Page<TaskModel>> {
return this.http.get<Page<TaskModel>>('/api/tasks', {
params: pageParams(pageNumber).set('before', DateTime.local().plus({ days: 7 }).toISODate())
});
}
示例7:
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;
示例8: it
it('convert null', () => {
expect(pipe.transform(null, null)).toEqual('N/A');
expect(pipe.transform(DateTime.local(), null)).toEqual('N/A');
expect(pipe.transform(null, DateTime.local())).toEqual('N/A');
});