宜搭开发包
    正在准备搜索索引...

    类 DateX

    DateX 是一个扩展了日期时间加减功能的 Date 类,提供了更方便的日期时间运算方法。

    主要功能包括:

    • add(duration: DateXDuration): 返回一个新的 DateX 实例,表示在当前日期基础上加上指定的时间段。
    • subtract(duration: DateXDuration): 返回一个新的 DateX 实例,表示在当前日期基础上减去指定的时间段。

    层级

    • Date
      • DateX
    索引

    构造函数

    • 返回 DateX

    • 参数

      • value: string | number

      返回 DateX

    • Creates a new Date.

      参数

      • year: number

        The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year.

      • monthIndex: number

        The month as a number between 0 and 11 (January to December).

      • 可选date: number

        The date as a number between 1 and 31.

      • 可选hours: number

        Must be supplied if minutes is supplied. A number from 0 to 23 (midnight to 11pm) that specifies the hour.

      • 可选minutes: number

        Must be supplied if seconds is supplied. A number from 0 to 59 that specifies the minutes.

      • 可选seconds: number

        Must be supplied if milliseconds is supplied. A number from 0 to 59 that specifies the seconds.

      • 可选ms: number

        A number from 0 to 999 that specifies the milliseconds.

      返回 DateX

    • 参数

      • vd: VarDate

      返回 DateX

    • 参数

      • value: string | number | Date

      返回 DateX

    属性

    getVarDate: () => VarDate
    ONE_DAY: number = ...
    ONE_WEEK: number = ...

    方法

    • Converts a Date object to a string.

      参数

      • hint: "default"

      返回 string

    • Converts a Date object to a string.

      参数

      • hint: "string"

      返回 string

    • Converts a Date object to a number.

      参数

      • hint: "number"

      返回 number

    • Converts a Date object to a string or number.

      参数

      • hint: string

        The strings "number", "string", or "default" to specify what primitive to return.

      返回 string | number

      A number if 'hint' was "number", a string if 'hint' was "string" or "default".

      If 'hint' was given something other than "number", "string", or "default".

    • Gets the day-of-the-month, using local time.

      返回 number

    • Gets the day of the week, using local time.

      返回 number

    • Gets the year, using local time.

      返回 number

    • Gets the hours in a date, using local time.

      返回 number

    • Gets the milliseconds of a Date, using local time.

      返回 number

    • Gets the minutes of a Date object, using local time.

      返回 number

    • Gets the month, using local time.

      返回 number

    • Gets the seconds of a Date object, using local time.

      返回 number

    • Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC.

      返回 number

    • Gets the difference in minutes between Universal Coordinated Time (UTC) and the time on the local computer.

      返回 number

    • Gets the day-of-the-month, using Universal Coordinated Time (UTC).

      返回 number

    • Gets the day of the week using Universal Coordinated Time (UTC).

      返回 number

    • Gets the year using Universal Coordinated Time (UTC).

      返回 number

    • Gets the hours value in a Date object using Universal Coordinated Time (UTC).

      返回 number

    • Gets the milliseconds of a Date object using Universal Coordinated Time (UTC).

      返回 number

    • Gets the minutes of a Date object using Universal Coordinated Time (UTC).

      返回 number

    • Gets the month of a Date object using Universal Coordinated Time (UTC).

      返回 number

    • Gets the seconds of a Date object using Universal Coordinated Time (UTC).

      返回 number

    • Sets the numeric day-of-the-month value of the Date object using local time.

      参数

      • date: number

        A numeric value equal to the day of the month.

      返回 number

    • Sets the year of the Date object using local time.

      参数

      • year: number

        A numeric value for the year.

      • 可选month: number

        A zero-based numeric value for the month (0 for January, 11 for December). Must be specified if numDate is specified.

      • 可选date: number

        A numeric value equal for the day of the month.

      返回 number

    • Sets the hour value in the Date object using local time.

      参数

      • hours: number

        A numeric value equal to the hours value.

      • 可选min: number

        A numeric value equal to the minutes value.

      • 可选sec: number

        A numeric value equal to the seconds value.

      • 可选ms: number

        A numeric value equal to the milliseconds value.

      返回 number

    • Sets the milliseconds value in the Date object using local time.

      参数

      • ms: number

        A numeric value equal to the millisecond value.

      返回 number

    • Sets the minutes value in the Date object using local time.

      参数

      • min: number

        A numeric value equal to the minutes value.

      • 可选sec: number

        A numeric value equal to the seconds value.

      • 可选ms: number

        A numeric value equal to the milliseconds value.

      返回 number

    • Sets the month value in the Date object using local time.

      参数

      • month: number

        A numeric value equal to the month. The value for January is 0, and other month values follow consecutively.

      • 可选date: number

        A numeric value representing the day of the month. If this value is not supplied, the value from a call to the getDate method is used.

      返回 number

    • Sets the seconds value in the Date object using local time.

      参数

      • sec: number

        A numeric value equal to the seconds value.

      • 可选ms: number

        A numeric value equal to the milliseconds value.

      返回 number

    • Sets the date and time value in the Date object.

      参数

      • time: number

        A numeric value representing the number of elapsed milliseconds since midnight, January 1, 1970 GMT.

      返回 number

    • Sets the numeric day of the month in the Date object using Universal Coordinated Time (UTC).

      参数

      • date: number

        A numeric value equal to the day of the month.

      返回 number

    • Sets the year value in the Date object using Universal Coordinated Time (UTC).

      参数

      • year: number

        A numeric value equal to the year.

      • 可选month: number

        A numeric value equal to the month. The value for January is 0, and other month values follow consecutively. Must be supplied if numDate is supplied.

      • 可选date: number

        A numeric value equal to the day of the month.

      返回 number

    • Sets the hours value in the Date object using Universal Coordinated Time (UTC).

      参数

      • hours: number

        A numeric value equal to the hours value.

      • 可选min: number

        A numeric value equal to the minutes value.

      • 可选sec: number

        A numeric value equal to the seconds value.

      • 可选ms: number

        A numeric value equal to the milliseconds value.

      返回 number

    • Sets the milliseconds value in the Date object using Universal Coordinated Time (UTC).

      参数

      • ms: number

        A numeric value equal to the millisecond value.

      返回 number

    • Sets the minutes value in the Date object using Universal Coordinated Time (UTC).

      参数

      • min: number

        A numeric value equal to the minutes value.

      • 可选sec: number

        A numeric value equal to the seconds value.

      • 可选ms: number

        A numeric value equal to the milliseconds value.

      返回 number

    • Sets the month value in the Date object using Universal Coordinated Time (UTC).

      参数

      • month: number

        A numeric value equal to the month. The value for January is 0, and other month values follow consecutively.

      • 可选date: number

        A numeric value representing the day of the month. If it is not supplied, the value from a call to the getUTCDate method is used.

      返回 number

    • Sets the seconds value in the Date object using Universal Coordinated Time (UTC).

      参数

      • sec: number

        A numeric value equal to the seconds value.

      • 可选ms: number

        A numeric value equal to the milliseconds value.

      返回 number

    • Returns a date as a string value.

      返回 string

    • Returns a date as a string value in ISO format.

      返回 string

    • Used by the JSON.stringify method to enable the transformation of an object's data for JavaScript Object Notation (JSON) serialization.

      参数

      • 可选key: any

      返回 string

    • Returns a date as a string value appropriate to the host environment's current locale.

      返回 string

    • Converts a date to a string by using the current or specified locale.

      参数

      • 可选locales: string | string[]

        A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.

      • 可选options: DateTimeFormatOptions

        An object that contains one or more properties that specify comparison options.

      返回 string

    • Converts a date to a string by using the current or specified locale.

      参数

      • 可选locales: LocalesArgument

        A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.

      • 可选options: DateTimeFormatOptions

        An object that contains one or more properties that specify comparison options.

      返回 string

    • Returns a value as a string value appropriate to the host environment's current locale.

      返回 string

    • Converts a date and time to a string by using the current or specified locale.

      参数

      • 可选locales: string | string[]

        A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.

      • 可选options: DateTimeFormatOptions

        An object that contains one or more properties that specify comparison options.

      返回 string

    • Converts a date and time to a string by using the current or specified locale.

      参数

      • 可选locales: LocalesArgument

        A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.

      • 可选options: DateTimeFormatOptions

        An object that contains one or more properties that specify comparison options.

      返回 string

    • Returns a time as a string value appropriate to the host environment's current locale.

      返回 string

    • Converts a time to a string by using the current or specified locale.

      参数

      • 可选locales: string | string[]

        A locale string or array of locale strings that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.

      • 可选options: DateTimeFormatOptions

        An object that contains one or more properties that specify comparison options.

      返回 string

    • Converts a time to a string by using the current or specified locale.

      参数

      • 可选locales: LocalesArgument

        A locale string, array of locale strings, Intl.Locale object, or array of Intl.Locale objects that contain one or more language or locale tags. If you include more than one locale string, list them in descending order of priority so that the first entry is the preferred locale. If you omit this parameter, the default locale of the JavaScript runtime is used.

      • 可选options: DateTimeFormatOptions

        An object that contains one or more properties that specify comparison options.

      返回 string

    • Returns a string representation of a date. The format of the string depends on the locale.

      返回 string

    • Returns a time as a string value.

      返回 string

    • Returns a date converted to a string using Universal Coordinated Time (UTC).

      返回 string

    • Returns the stored time value in milliseconds since midnight, January 1, 1970 UTC.

      返回 number

    • Returns the number of milliseconds elapsed since midnight, January 1, 1970 Universal Coordinated Time (UTC).

      返回 number

    • Parses a string containing a date, and returns the number of milliseconds between that date and midnight, January 1, 1970.

      参数

      • s: string

        A date string

      返回 number

    • Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date.

      参数

      • year: number

        The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year.

      • monthIndex: number

        The month as a number between 0 and 11 (January to December).

      • 可选date: number

        The date as a number between 1 and 31.

      • 可选hours: number

        Must be supplied if minutes is supplied. A number from 0 to 23 (midnight to 11pm) that specifies the hour.

      • 可选minutes: number

        Must be supplied if seconds is supplied. A number from 0 to 59 that specifies the minutes.

      • 可选seconds: number

        Must be supplied if milliseconds is supplied. A number from 0 to 59 that specifies the seconds.

      • 可选ms: number

        A number from 0 to 999 that specifies the milliseconds.

      返回 number

    • Returns the number of milliseconds between midnight, January 1, 1970 Universal Coordinated Time (UTC) (or GMT) and the specified date.

      参数

      • year: number

        The full year designation is required for cross-century date accuracy. If year is between 0 and 99 is used, then year is assumed to be 1900 + year.

      • 可选monthIndex: number

        The month as a number between 0 and 11 (January to December).

      • 可选date: number

        The date as a number between 1 and 31.

      • 可选hours: number

        Must be supplied if minutes is supplied. A number from 0 to 23 (midnight to 11pm) that specifies the hour.

      • 可选minutes: number

        Must be supplied if seconds is supplied. A number from 0 to 59 that specifies the minutes.

      • 可选seconds: number

        Must be supplied if milliseconds is supplied. A number from 0 to 59 that specifies the seconds.

      • 可选ms: number

        A number from 0 to 999 that specifies the milliseconds.

      返回 number