• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript luxon.DateTime类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中luxon.DateTime的典型用法代码示例。如果您正苦于以下问题:TypeScript DateTime类的具体用法?TypeScript DateTime怎么用?TypeScript DateTime使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了DateTime类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: convertDate

function convertDate(date: string | Date): DateTime {
  if (typeof date === 'string') {
    return DateTime.fromISO(date);
  } else {
    return DateTime.fromJSDate(date);
  }
}
开发者ID:ha4us,项目名称:ha4us.old,代码行数:7,代码来源:templates.ts


示例2: it

 it('should parse the JSON into a JobExecution model with step execution', () => {
   const jobExecution = JobExecution.fromJSON(JOBS_EXECUTIONS_1);
   expect(jobExecution.name).toBe('job1');
   expect(jobExecution.startTime.toISO()).toBe(DateTime.fromISO('2017-08-11T06:15:50.027Z').toISO());
   expect(jobExecution.endTime.toISO()).toBe(DateTime.fromISO('2017-08-11T06:15:50.067Z').toISO());
   expect(jobExecution.stepExecutionCount).toBe(1);
   expect(jobExecution.status).toBe('COMPLETED');
   expect(jobExecution.exitCode).toBe('COMPLETED');
   expect(jobExecution.exitMessage).toBe('');
   expect(jobExecution.jobExecutionId).toBe(1);
   expect(jobExecution.taskExecutionId).toBe(2);
   expect(jobExecution.jobInstanceId).toBe(1);
   expect(jobExecution.jobParametersString).toBe('--spring.cloud.task.executionid=2');
   expect(jobExecution.restartable).toBe(false);
   expect(jobExecution.abandonable).toBe(false);
   expect(jobExecution.stoppable).toBe(false);
   expect(jobExecution.defined).toBe(true);
   expect(jobExecution.stepExecutions[0].id.toString()).toBe('1');
   expect(jobExecution.stepExecutions[0].name).toBe('job1step1');
   expect(jobExecution.stepExecutions[0].readCount).toBe(0);
   expect(jobExecution.stepExecutions[0].writeCount).toBe(0);
   expect(jobExecution.stepExecutions[0].commitCount).toBe(1);
   expect(jobExecution.stepExecutions[0].rollbackCount).toBe(0);
   expect(jobExecution.stepExecutions[0].readSkipCount).toBe(0);
   expect(jobExecution.stepExecutions[0].processSkipCount).toBe(0);
   expect(jobExecution.stepExecutions[0].writeSkipCount).toBe(0);
   expect(jobExecution.stepExecutions[0].filterCount).toBe(0);
   expect(jobExecution.stepExecutions[0].skipCount).toBe(0);
   expect(jobExecution.stepExecutions[0].startTime.toISO()).toBe(DateTime.fromISO('2017-08-11T06:15:50.046Z').toISO());
   expect(jobExecution.stepExecutions[0].endTime.toISO()).toBe(DateTime.fromISO('2017-08-11T06:15:50.064Z').toISO());
   expect(jobExecution.stepExecutions[0].status).toBe('COMPLETED');
 });
开发者ID:BoykoAlex,项目名称:spring-cloud-dataflow-ui,代码行数:32,代码来源:job-execution.model.spec.ts


示例3: fromJSON

 static fromJSON(input): JobExecution {
   const jobExecution: JobExecution = new JobExecution();
   jobExecution.name = input.name;
   jobExecution.startTime = DateTime.fromISO(input.jobExecution.startTime);
   jobExecution.stepExecutionCount = input.stepExecutionCount;
   jobExecution.status = input.jobExecution.status;
   jobExecution.jobExecutionId = input.jobExecution.id;
   jobExecution.taskExecutionId = input.taskExecutionId;
   jobExecution.jobInstanceId = input.jobExecution.jobInstance.id;
   jobExecution.restartable = input.restartable;
   jobExecution.abandonable = input.abandonable;
   jobExecution.stoppable = input.stoppable;
   jobExecution.defined = input.defined;
   if (input.jobExecution.endTime) {
     jobExecution.endTime = DateTime.fromISO(input.jobExecution.endTime);
   }
   if (input.jobExecution.exitStatus) {
     jobExecution.exitCode = input.jobExecution.exitStatus.exitCode;
     jobExecution.exitMessage = input.jobExecution.exitStatus.exitDescription;
   }
   jobExecution.jobParametersString = input.jobParametersString;
   if (input.jobExecution.stepExecutions) {
     jobExecution.stepExecutions = input.jobExecution.stepExecutions.map(StepExecution.fromJSON);
   }
   return jobExecution;
 }
开发者ID:BoykoAlex,项目名称:spring-cloud-dataflow-ui,代码行数:26,代码来源:job-execution.model.ts


示例4: expectedDate

export function expectedDate(startDate: DateTime, currentLocalDate: DateTime, targetZone: string): Date {
  const targetOffset = startDate.setZone(targetZone).offset
  const { zoneName: systemZone } = currentLocalDate
  const {
    offset: systemOffset,
  } = startDate.setZone(systemZone)

  const netOffset = targetOffset - systemOffset
  const hours = -((netOffset / 60) % 24)
  const minutes = -(netOffset % 60)
  return startDate.plus({ hours, minutes }).toJSDate()
}
开发者ID:jkbrzt,项目名称:rrule,代码行数:12,代码来源:utils.ts


示例5: fromJSON

 static fromJSON(jsonItem): TaskExecution {
   return new TaskExecution(
     jsonItem.executionId,
     jsonItem.exitCode,
     jsonItem.taskName,
     jsonItem.startTime ? DateTime.fromISO(jsonItem.startTime) : null,
     jsonItem.endTime ? DateTime.fromISO(jsonItem.endTime) : null,
     jsonItem.exitMessage,
     jsonItem.arguments,
     jsonItem.jobExecutionIds,
     jsonItem.errorMessage,
     jsonItem.externalExecutionId);
 }
开发者ID:BoykoAlex,项目名称:spring-cloud-dataflow-ui,代码行数:13,代码来源:task-execution.ts


示例6: transform

 transform(value: string | DateTime, format: string = null): string {
   let m: DateTime;
   if (value instanceof DateTime) {
     m = value;
   } else {
     m = DateTime.fromISO(value as string);
   }
   if (m.isValid) {
     return m.toFormat(format != null ? format : DateTimeUtils.DEFAULT);
   } else {
     return 'N/A';
   }
 }
开发者ID:BoykoAlex,项目名称:spring-cloud-dataflow-ui,代码行数:13,代码来源:dataflow-date-time.pipe.ts


示例7: 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


示例8: 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


示例9: timestampToArray

 timestampToArray(ms: number): number[] {
   return luxonToArray(
     LuxonDateTime.fromMillis(ms, {
       zone: this.timeZoneName
     })
   )
 }
开发者ID:BorjaPintos,项目名称:fullcalendar,代码行数:7,代码来源:main.ts


示例10: age

  protected async age(opts: CommandOptions) {
    let username;
    const parsed = opts.parameters.match(/([^@]\S*)/g);

    if (_.isNil(parsed)) {
      username = opts.sender.username;
    } else {
      username = parsed[0].toLowerCase();
    }

    const user = await global.users.getByName(username);
    if (_.isNil(user) || _.isNil(user.time) || _.isNil(user.time.created_at)) {
      sendMessage(prepare('age.failed', { username }), opts.sender);
    } else {
      const units: string[] = ['years', 'months', 'days', 'hours', 'minutes'];
      const diff = DateTime.fromMillis(new Date(user.time.created_at).getTime()).diffNow(['years', 'months', 'days', 'hours', 'minutes']);
      const output: string[] = [];
      for (const unit of units) {
        if (diff[unit]) {
          const v = -Number(diff[unit]).toFixed();
          output.push(v + ' ' + getLocalizedName(v, 'core.' + unit));
        }
      }
      if (output.length === 0) {
        output.push(0 + ' ' + getLocalizedName(0, 'core.minutes'));
      }
      sendMessage(prepare('age.success.' + (opts.sender.username === username.toLowerCase() ? 'withoutUsername' : 'withUsername'), {
          username,
          diff: output.join(', '),
        }), opts.sender);
    }
  }
开发者ID:sogehige,项目名称:SogeBot,代码行数:32,代码来源:userinfo.ts



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript luxon.Duration类代码示例发布时间:2022-05-25
下一篇:
TypeScript luxi.action函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap