當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。