当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript DateTime.local方法代码示例

本文整理汇总了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()
    })
开发者ID:jkbrzt,项目名称:rrule,代码行数:31,代码来源:rruleset.test.ts

示例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()
  })
开发者ID:jkbrzt,项目名称:rrule,代码行数:13,代码来源:datewithzone.test.ts

示例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);
 });
开发者ID:tangkaisky,项目名称:r2,代码行数:41,代码来源:QuoteAggregatorImpl.test.ts

示例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));
  }
开发者ID:Ninja-Squad,项目名称:globe42,代码行数:39,代码来源:spent-time-statistics.component.ts

示例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),
    });
  }
开发者ID:huttarichard,项目名称:instagram-private-api,代码行数:37,代码来源:media.repository.ts

示例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())
   });
 }
开发者ID:Ninja-Squad,项目名称:globe42,代码行数:5,代码来源:task.service.ts

示例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;
开发者ID:horiuchi,项目名称:DefinitelyTyped,代码行数:30,代码来源:luxon-tests.ts

示例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');
 });
开发者ID:BoykoAlex,项目名称:spring-cloud-dataflow-ui,代码行数:5,代码来源:dataflow-duration.pipe.spec.ts


注:本文中的luxon.DateTime.local方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。