Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • TimeUtils

Index

Methods

Static dateId

  • dateId(t?: Date): number

Static diffDay

  • diffDay(a: Date, b: Date, fixOne?: boolean): number
  • 计算俩日期时间差,如果a比b小,返回负数

    Parameters

    • a: Date
    • b: Date
    • Default value fixOne: boolean = false

    Returns number

Static formatDate

  • formatDate(date: Date): string

Static formatDateTime

  • formatDateTime(date: Date): string

Static getFirstDayOfWeek

  • getFirstDayOfWeek(d?: Date): Date

Static getFirstOfDay

  • getFirstOfDay(d?: Date): Date

Static getNextFirstOfDay

  • getNextFirstOfDay(d?: Date): Date

Static monthId

  • monthId(d?: Date): number

Static parseDate

  • parseDate(s: string): Date

Static secondToTime

  • secondToTime(time?: number, partition?: string, showHour?: boolean): string
  • 秒数转换为时间形式。

    Parameters

    • Default value time: number = 0

      秒数

    • Default value partition: string = ":"

      分隔符

    • Default value showHour: boolean = true

      是否显示小时

    Returns string

    返回一个以分隔符分割的时, 分, 秒

    比如: time = 4351; secondToTime(time)返回字符串01:12:31;

Static timeToMillisecond

  • timeToMillisecond(time: string, partition?: string): string
  • 时间形式转换为毫秒数。

    throws

    Error Exception

    用法1 trace(MillisecondTransform.timeToMillisecond("00:60:00")) 输出 3600000

    用法2 trace(MillisecondTransform.timeToMillisecond("00.60.00",".")) 输出 3600000

    Parameters

    • time: string

      以指定分隔符分割的时间字符串

    • Default value partition: string = ":"

      分隔符

    Returns string

    毫秒数显示的字符串

Static weekId

  • weekId(d?: Date, first?: boolean): number
  • 计算周ID

    Parameters

    • Default value d: Date = null

      指定计算日期

    • Default value first: boolean = true

    Returns number

    周ID

Generated using TypeDoc