Time#

class Time(**properties: Any)#

Superclasses: Object, Object

This is the ICalTime instance.

Constructors#

class Time
classmethod new() Time#

Creates a new Time.

Added in version 1.0.

classmethod new_current_with_zone(zone: Timezone | None = None) Time#

Creates a Time according to the timezone and current time.

Added in version 1.0.

Parameters:

zone – The timezone used to create a Time according to the current time

classmethod new_from_day_of_year(day: int, year: int) Time#

Creates a new time, given a day of year and a year.

Added in version 1.0.

Parameters:
  • day – The day of a year

  • year – The year

classmethod new_from_string(str: str) Time#

Creates a time from an ISO format string.

Added in version 1.0.

Parameters:

str – The ISO format string

classmethod new_from_timet_with_zone(v: int, is_date: int, zone: Timezone | None = None) Time#

Converts seconds past UNIX epoch to a timetype, using timezones.

Added in version 1.0.

Parameters:
  • v – The seconds past since epoch time

  • is_date – Whether it is a date type, 1 if yes, 0 if not

  • zone – The timezone, or None

classmethod new_null_date() Time#

Creates a null date, which indicates no time has been set.

Added in version 1.0.

classmethod new_null_time() Time#

Creates a default time which is an epoch time.

Added in version 1.0.

classmethod new_today() Time#

Creates a Time representing today.

Added in version 1.0.

Methods#

class Time
add(d: Duration) Time#

Adds a time duration on the time.

Added in version 2.0.

Parameters:

d – A Duration as the difference

adjust(days: int, hours: int, minutes: int, seconds: int) None#

Adds or subtracts a number of days, hours, minutes and seconds from tt.

Added in version 1.0.

Parameters:
  • days – Difference of days adjusted

  • hours – Difference of hours adjusted

  • minutes – Difference of minutes adjusted

  • seconds – Difference of seconds adjusted

as_ical_string() str#

Returns a string representation of the time, in RFC2445 format.

Added in version 1.0.

as_timet() int#

Returns the time as seconds past the UNIX epoch.

Added in version 1.0.

as_timet_with_zone(zone: Timezone | None = None) int#

Returns the time as seconds past the UNIX epoch, using timezones.

Added in version 1.0.

Parameters:

zone – The timezone

clone() Time#

Creates a new Time, copy of timetype.

Added in version 1.0.

compare(b: Time) int#

i_cal_time_compare returns an integer indicating the result of the comparison, as follow:

Added in version 1.0.

Parameters:

b – The Time to be compared

compare_date_only(b: Time) int#

Like compare(), but only use the date parts.

Added in version 1.0.

Parameters:

b – The Time to be compared

compare_date_only_tz(b: Time, zone: Timezone | None = None) int#

Like i_cal_time_compare_tz(), but only use the date parts; accepts timezone.

Added in version 1.0.

Parameters:
  • b – The Time to be compared

  • zone – The target timezone

convert_timezone(from_zone: Timezone | None = None, to_zone: Timezone | None = None) None#

Convert time from one timezone to another.

Added in version 1.0.

Parameters:
  • from_zone – From timezone

  • to_zone – To timezone

convert_to_zone(zone: Timezone | None = None) Time#

Converts tt to zone and return new Time object.

Added in version 1.0.

Parameters:

zone – The target timezone

convert_to_zone_inplace(zone: Timezone | None = None) None#

Converts tt to zone and store the result into tt.

Added in version 3.0.5.

Parameters:

zone – The target timezone

day_of_week() int#

Returns the day of the week of the given time. Sunday is 1.

Added in version 1.0.

day_of_year() int#

Returns the day of the year of the given time.

Added in version 1.0.

classmethod days_in_month(year: int) int#

Gets the number of days in the target month in the target year.

Added in version 1.0.

Parameters:

year – The target year

classmethod days_in_year() int#

Returns the number of days in this year.

Added in version 2.0.

classmethod days_is_leap_year() bool#

Checks whether a year is a leap year.

Added in version 1.0.

get_date() tuple[int, int, int]#

Gets the year/month/date parts of the timetype in one call.

Added in version 1.0.

get_day() int#

Gets the day of Time.

Added in version 1.0.

get_hour() int#

Gets the hour of Time.

Added in version 1.0.

get_minute() int#

Gets the minute of Time.

Added in version 1.0.

get_month() int#

Gets the month of Time.

Added in version 1.0.

get_second() int#

Gets the second of Time.

Added in version 1.0.

get_time() tuple[int, int, int]#

Gets the hour/minute/second parts of the timetype in one call.

Added in version 1.0.

get_timezone() Timezone#

Returns the timezone, the Timezone object is cached and can be either unreferenced once the last instance is used or can be kept until free_global_objects() is called (usually at the very end of the program).

Added in version 1.0.

get_tzid() str | None#

Returns the tzid, or NULL for a floating time.

Added in version 1.0.

get_year() int#

Gets the year of Time.

Added in version 1.0.

is_date() bool#

Returns true if time is of DATE type, false if DATE-TIME.

Added in version 1.0.

is_daylight() bool#

Gets the is_daylight of Time.

Added in version 1.0.

is_null_time() bool#

Returns true if the time is null.

Added in version 1.0.

is_utc() bool#

Returns true if time is relative to UTC zone.

Added in version 1.0.

is_valid_time() bool#

Returns true if the time is null.

Added in version 1.0.

normalize() Time#

Normalizes the icaltime, so that all fields are within the normal range.

Added in version 1.0.

normalize_inplace() None#

Normalizes the tt, so that all fields are within the normal range.

Added in version 3.0.5.

set_date(year: int, month: int, day: int) None#

Sets the year/month/date parts of the timetype in one call. This doesn’t verify validity of the given date.

Added in version 1.0.

Parameters:
  • year – The ‘year’ part of the date

  • month – The ‘month’ part of the date

  • day – The ‘day’ part of the date

set_day(day: int) None#

Sets the day of Time.

Added in version 1.0.

Parameters:

day – The day

set_hour(hour: int) None#

Sets the hour of Time.

Added in version 1.0.

Parameters:

hour – The hour

set_is_date(is_date: bool) None#

Sets the is_date of Time.

Added in version 1.0.

Parameters:

is_date – The is_date

set_is_daylight(is_daylight: bool) None#

Sets the is_daylight of Time.

Added in version 1.0.

Parameters:

is_daylight – The is_daylight

set_minute(minute: int) None#

Sets the minute of Time.

Added in version 1.0.

Parameters:

minute – The minute

set_month(month: int) None#

Sets the month of Time.

Added in version 1.0.

Parameters:

month – The month

set_second(second: int) None#

Sets the second of Time.

Added in version 1.0.

Parameters:

second – The second

set_time(hour: int, minute: int, second: int) None#

Sets the hour/minute/second parts of the timetype in one call. This doesn’t verify validity of the given time.

Added in version 1.0.

Parameters:
  • hour – The ‘hour’ part of the time

  • minute – The ‘minute’ part of the time

  • second – The ‘second’ part of the time

set_timezone(zone: Timezone | None = None) None#

Sets the timezone of the tt.

Added in version 1.0.

Parameters:

zone – The timezone

set_year(year: int) None#

Sets the year of Time.

Added in version 1.0.

Parameters:

year – The year

start_doy_week(fdow: int) int#

Returns the day of the year for the first day of the week that the given time is within.

Added in version 1.0.

Parameters:

fdow – The first day of the week

subtract(t2: Time) Duration#

Gets the duration between two time.

Added in version 2.0.

Parameters:

t2 – The subtracting Time

classmethod timezone_expand_vtimezone(end_year: int, changes: Array) None#

Applies a list of timezone changes on the array of components until the end year.

Added in version 2.0.

Parameters:
  • end_year – The end year

  • changes – The changes to be applies

week_number() int#

Returns the week number for the week the given time is within.

Added in version 1.0.