Class VCardTime

Describes a vCard time, which has slight differences to the ICAL.Time. Properties can be null if not specified, for example for dates with reduced accuracy or truncation.

Note that currently not all methods are correctly re-implemented for VCardTime. For example, comparison will have undefined results when some members are null.

Also, normalization is not yet implemented for this class!

Alias

ICAL.VCardTime

Hierarchy

Constructors

  • Creates a new ICAL.VCardTime instance.

    Parameters

    • data: VCardTimeData

      The data for the time instance

    • zone: Timezone | UtcOffset

      The timezone to use

    • icalType: "date-and-or-time" | "date" | "date-time" | "time" = 'date-and-or-time'

      The type for this date/time object

    Returns VCardTime

Properties

_cachedUnixTime: null | number = null
_time: Required<TimeData>
day: number
hour: number
icalclass: "vcardtime" = 'vcardtime'

The class identifier.

icaltype: "date-and-or-time" | "date" | "date-time" | "time"

The type name, to be used in the jCal object.

isDate: boolean
minute: number
month: number
second: number
wrappedJSObject: Time
year: number
zone?: Timezone

The timezone for this time.

DEFAULT_WEEK_START: 2 = 2

The default weekday for the WKST part.

Constant

Default

ICAL.Time.MONDAY
FRIDAY: FRIDAY = WeekDay.FRIDAY
MONDAY: MONDAY = WeekDay.MONDAY
SATURDAY: SATURDAY = WeekDay.SATURDAY
SUNDAY: SUNDAY = WeekDay.SUNDAY
THURSDAY: THURSDAY = WeekDay.THURSDAY
TUESDAY: TUESDAY = WeekDay.TUESDAY
WEDNESDAY: WEDNESDAY = WeekDay.WEDNESDAY
_dowCache: Record<number, number> = {}
_wnCache: Record<number, number> = {}
daysInYearPassedMonth: number[][] = ...

The days that have passed in the year after a given month. The array has two members, one being an array of passed days for non-leap years, the other analog for leap years.

Example

var isLeapYear = ICAL.Time.isLeapYear(year);
var passedDays = ICAL.Time.daysInYearPassedMonth[isLeapYear][month];
fromData: ((aData, aZone?) => Time) = ...

Type declaration

    • (aData, aZone?): Time
    • Creates a new ICAL.Time instance from the the passed data object.

      Parameters

      • aData: TimeData

        Time initialization

      • Optional aZone: Timezone

        Timezone this position occurs in

      Returns Time

Accessors

  • get epochTime(): Time
  • January 1st, 1970 as an ICAL.Time.

    Returns Time

    Constant

    Instance

Methods

  • Adds the duration to the current time. The instance is modified in place.

    Parameters

    • aDuration: Duration

      The duration to add

    Returns void

  • Adjust the date/time by the given offset

    Parameters

    • aExtraDays: number

      The extra amount of days

    • aExtraHours: number

      The extra amount of hours

    • aExtraMinutes: number

      The extra amount of minutes

    • aExtraSeconds: number

      The extra amount of seconds

    • Optional aTime: Required<TimeData>

      The time to adjust, defaults to the current instance.

    Returns VCardTime

  • Compares the ICAL.Time instance with another one.

    Parameters

    Returns number

    -1, 0 or 1 for less/equal/greater

  • Compares only the date part of this instance with another one.

    Parameters

    • other: Duration

      The instance to compare with

    • tz: Timezone

      The timezone to compare in

    Returns number

    -1, 0 or 1 for less/equal/greater

  • Convert the instance into another timezone. The returned ICAL.Time instance is always a copy.

    Parameters

    Returns Time

    The copy, converted to the zone

  • Calculate the day of week.

    Parameters

    • Optional aWeekStart: WeekDay

      The week start weekday, defaults to SUNDAY

    Returns WeekDay

  • Returns a copy of the current date/time, shifted to the end of the month. The resulting ICAL.Time instance is of icaltype date, even if this is a date-time.

    Returns Time

    The end of the month (cloned)

  • Returns a copy of the current date/time, shifted to the end of the week. The resulting ICAL.Time instance is of icaltype date, even if this is a date-time.

    Parameters

    • Optional aWeekStart: WeekDay

      The week start weekday, defaults to SUNDAY

    Returns Time

    The end of the week (cloned)

  • Returns a copy of the current date/time, shifted to the end of the year. The resulting ICAL.Time instance is of icaltype date, even if this is a date-time.

    Returns Time

    The end of the year (cloned)

  • Sets up the current instance using members from the passed data object.

    Parameters

    • Optional aData: TimeData

      Time initialization

    • Optional aZone: Timezone

      Timezone this position occurs in

    Returns VCardTime

  • Set up the current instance from the Javascript date value.

    Parameters

    • aDate: null | Date

      The Javascript Date to read, or null to reset

    • Optional useUTC: boolean

      If true, the UTC values of the date will be used

    Returns VCardTime

  • Sets up the current instance from unix time, the number of seconds since January 1st, 1970.

    Parameters

    • seconds: number

      The seconds to set up with

    Returns void

  • Get the dominical letter for the current year. Letters range from A - G for common years, and AG to GF for leap years.

    Returns string

    The dominical letter.

  • Checks if current time is the nth weekday, relative to the current month. Will always return false when rule resolves outside of current month.

    Parameters

    • aDayOfWeek: WeekDay

      Day of week to check

    • aPos: number

      Relative position

    Returns boolean

    True, if it is the nth weekday

  • Finds the nthWeekDay relative to the current month (not day). The returned value is a day relative the month that this month belongs to so 1 would indicate the first of the month and 40 would indicate a day in the following month.

    Parameters

    • aDayOfWeek: number

      Day of the week see the day name constants

    • aPos: number

      Nth occurrence of a given week day values of 1 and 0 both indicate the first weekday of that type. aPos may be either positive or negative

    Returns number

    numeric value indicating a day relative to the current month of this time object

  • Reset the time instance to epoch time

    Returns void

  • Reset the time instance to the given date/time values.

    Parameters

    • year: number

      The year to set

    • month: number

      The month to set

    • day: number

      The day to set

    • hour: number

      The hour to set

    • minute: number

      The minute to set

    • second: number

      The second to set

    • Optional timezone: Timezone

      The timezone to set

    Returns void

  • First calculates the start of the week, then returns the day of year for this date. If the day falls into the previous year, the day is zero or negative.

    Parameters

    • Optional aFirstDayOfWeek: WeekDay

      The week start weekday, defaults to SUNDAY

    Returns number

    The calculated day of year

  • Returns a copy of the current date/time, rewound to the start of the month. The resulting ICAL.Time instance is of icaltype date, even if this is a date-time.

    Returns Time

    The start of the month (cloned)

  • Returns a copy of the current date/time, rewound to the start of the week. The resulting ICAL.Time instance is of icaltype date, even if this is a date-time.

    Parameters

    • Optional aWeekStart: WeekDay

      The week start weekday, defaults to SUNDAY

    Returns Time

    The start of the week (cloned)

  • Returns a copy of the current date/time, rewound to the start of the year. The resulting ICAL.Time instance is of icaltype date, even if this is a date-time.

    Returns Time

    The start of the year (cloned)

  • Subtract the date details (excluding timezone). Useful for finding the relative difference between two time objects excluding their timezone differences.

    Parameters

    • aDate: Time

      The date to subtract

    Returns Duration

    The difference as a duration

  • Returns an RFC 6350 compliant representation of this object.

    Returns string

    vcard date/time string

  • Converts the current instance to a Javascript date

    Returns Date

  • Converts time to into Object which can be serialized then re-created using the constructor.

    Returns Record<string, any>

    Example

    // toJSON will automatically be called
    var json = JSON.stringify(mytime);

    var deserialized = JSON.parse(json);

    var time = new ICAL.Time(deserialized);
  • The string representation of this date/time, in jCard form (including : and - separators).

    Returns string

  • Converts the current instance to seconds since January 1st 1970.

    Returns number

    Seconds since 1970

  • Calculates the UTC offset of the current date/time in the timezone it is in.

    Returns number

    UTC offset in seconds

  • Calculates the ISO 8601 week number. The first week of a year is the week that contains the first Thursday. The year can have 53 weeks, if January 1st is a Friday.

    Note there are regions where the first week of the year is the one that starts on January 1st, which may offset the week number. Also, if a different week start is specified, this will also affect the week number.

    Parameters

    • aWeekStart: WeekDay

      The weekday the week starts with

    Returns number

    The ISO week number

    See

    ICAL.Time.weekOneStarts

  • Parameters

    • a: any
    • b: any
    • attr: any

    Returns 0 | 1 | -1

  • Returns the days in the given month

    Parameters

    • month: number

      The month to check

    • year: number

      The year to check

    Returns number

    The number of days in the month

  • Returns a new ICAL.VCardTime instance from a date and/or time string.

    Parameters

    • aValue: string

      The string to create from

    • Optional aIcalType: "date-and-or-time" | "date" | "date-time" | "time"

      The type for this instance, e.g. date-and-or-time

    Returns VCardTime

    The date/time instance

  • Returns a new ICAL.Time instance from a date string, e.g 2015-01-02.

    Parameters

    • aValue: string

      The string to create from

    Returns Time

    The date/time instance

  • Returns a new ICAL.Time instance from a date-time string, e.g 2015-01-02T03:04:05. If a property is specified, the timezone is set up from the property's TZID parameter.

    Parameters

    • aValue: string

      The string to create from

    • Optional prop: Property

      The property the date belongs to

    Returns Time

    The date/time instance

  • Create a new ICAL.Time from the day of year and year. The date is returned in floating timezone.

    Parameters

    • aDayOfYear: number

      The day of year

    • aYear: number

      The year to create the instance in

    Returns Time

    The created instance with the calculated date

  • Creates a new ICAL.Time instance from the given Javascript Date.

    Parameters

    • aDate: null | Date

      The Javascript Date to read, or null to reset

    • useUTC: boolean

      If true, the UTC values of the date will be used

    Returns Time

  • Returns a new ICAL.Time instance from a date or date-time string,

    Parameters

    • aValue: string

      The string to create from

    • Optional aProperty: Property

      The property the date belongs to

    Returns Time

    The date/time instance

  • Returns a new ICAL.Time instance from a date string, e.g 2015-01-02.

    Parameters

    • str: string

      The string to create from

    Returns Time

    The date/time instance

    Deprecated

    Use ICAL.Time.fromDateString instead

  • Get the dominical letter for the given year. Letters range from A - G for common years, and AG to GF for leap years.

    Parameters

    • yr: number

      The year to retrieve the letter for

    Returns string

    The dominical letter.

  • Checks if the year is a leap year

    Parameters

    • year: number

      The year to check

    Returns boolean

    True, if the year is a leap year

  • Creates a new ICAL.Time instance from the current moment. The instance is “floating” - has no timezone relation. To create an instance considering the time zone, call ICAL.Time.fromJSDate(new Date(), true)

    Returns Time

  • Returns the date on which ISO week number 1 starts.

    Parameters

    • aYear: number

      The year to search in

    • aWeekStart: WeekDay

      The week start weekday, used for calculation.

    Returns Time

    The date on which week number 1 starts

    See

    ICAL.Time#weekNumber

Generated using TypeDoc