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

TypeScript moment.isDuration函数代码示例

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

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



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

示例1: function

 parse: function(eventInput, source) {
   if (
     isTimeString(eventInput.start) || moment.isDuration(eventInput.start) ||
     isTimeString(eventInput.end) || moment.isDuration(eventInput.end)
   ) {
     return RecurringEventDef.parse(eventInput, source)
   } else {
     return SingleEventDef.parse(eventInput, source)
   }
 }
开发者ID:caseyjhol,项目名称:fullcalendar,代码行数:10,代码来源:EventDefParser.ts


示例2: computeRangeAs

// Computes the number of units (like "hours") in the given range.
// Range can be a {start,end} object, separate start/end args, or a Duration.
// Results are based on Moment's .as() and .diff() methods, so results can depend on internal handling
// of month-diffing logic (which tends to vary from version to version).
function computeRangeAs(unit, start, end) {

  if (end != null) { // given start, end
    return end.diff(start, unit, true)
  } else if (moment.isDuration(start)) { // given duration
    return start.as(unit)
  } else { // given { start, end } range object
    return start.end.diff(start.start, unit, true)
  }
}
开发者ID:enhazappe,项目名称:fullcalendar,代码行数:14,代码来源:util.ts


示例3: function

newMomentProto.time = function(time) {

  // Fallback to the original method (if there is one) if this moment wasn't created via FullCalendar.
  // `time` is a generic enough method name where this precaution is necessary to avoid collisions w/ other plugins.
  if (!this._fullCalendar) {
    return oldMomentProto.time.apply(this, arguments)
  }

  if (time == null) { // getter
    return moment.duration({
      hours: this.hours(),
      minutes: this.minutes(),
      seconds: this.seconds(),
      milliseconds: this.milliseconds()
    })
  } else { // setter

    this._ambigTime = false // mark that the moment now has a time

    if (!moment.isDuration(time) && !moment.isMoment(time)) {
      time = moment.duration(time)
    }

    // The day value should cause overflow (so 24 hours becomes 00:00:00 of next day).
    // Only for Duration times, not Moment times.
    let dayHours = 0
    if (moment.isDuration(time)) {
      dayHours = Math.floor(time.asDays()) * 24
    }

    // We need to set the individual fields.
    // Can't use startOf('day') then add duration. In case of DST at start of day.
    return this.hours(dayHours + time.hours())
      .minutes(time.minutes())
      .seconds(time.seconds())
      .milliseconds(time.milliseconds())
  }
}
开发者ID:caseyjhol,项目名称:fullcalendar,代码行数:38,代码来源:moment-ext.ts


示例4:

export const formatCountdown = (countdown: Duration) => {
  let result = ''

  if (countdown && moment.isDuration(countdown)) {
    let minutes: any = countdown.minutes()
    let seconds: any = countdown.seconds()

    if (minutes < 10) {
      minutes = `0${minutes}`
    }
    if (seconds < 10) {
      seconds = `0${seconds}`
    }

    result = `${minutes}:${seconds}`
  }

  return result
}
开发者ID:appirio-digital,项目名称:react-native-session-timer-modal,代码行数:19,代码来源:utils.ts


示例5: coerce

  {
    name: 'duration',

    coerce(value: any, state: State, options: ValidationOptions) {
      try {
        if (typeof value === 'string' || typeof value === 'number') {
          return ensureDuration(value);
        }
      } catch (e) {
        return this.createError('duration.parse', { value, message: e.message }, state, options);
      }

      return value;
    },
    pre(value: any, state: State, options: ValidationOptions) {
      if (!isDuration(value)) {
        return this.createError('duration.base', { value }, state, options);
      }

      return value;
    },
    rules: [anyCustomRule],
  },
  {
    name: 'number',

    base: Joi.number(),
    coerce(value: any, state: State, options: ValidationOptions) {
      // If value isn't defined, let Joi handle default value if it's defined.
      if (value === undefined) {
        return value;
开发者ID:elastic,项目名称:kibana,代码行数:31,代码来源:index.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript moment.isMoment函数代码示例发布时间:2022-05-25
下一篇:
TypeScript moment.duration函数代码示例发布时间: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