Time#
This is the ICalTime instance.
Constructors#
- class Time
-
- classmethod new_current_with_zone(zone: Timezone | None = None) Time#
Creates a
Timeaccording to the timezone and current time.Added in version 1.0.
- Parameters:
zone – The timezone used to create a
Timeaccording 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.
Methods#
- class Time
- add(d: Duration) Time#
Adds a time duration on the time.
Added in version 2.0.
- Parameters:
d – A
Durationas 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_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
- 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
Timeto be compared
- compare_date_only(b: Time) int#
Like
compare(), but only use the date parts.Added in version 1.0.
- Parameters:
b – The
Timeto 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
Timeto be comparedzone – 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
tttozoneand return newTimeobject.Added in version 1.0.
- Parameters:
zone – The target timezone
- convert_to_zone_inplace(zone: Timezone | None = None) None#
Converts
tttozoneand store the result intott.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.
- 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
- get_date() tuple[int, int, int]#
Gets the year/month/date parts of the
timetypein one call.Added in version 1.0.
- get_time() tuple[int, int, int]#
Gets the hour/minute/second parts of the
timetypein one call.Added in version 1.0.
- get_timezone() Timezone#
Returns the timezone, the
Timezoneobject is cached and can be either unreferenced once the last instance is used or can be kept untilfree_global_objects()is called (usually at the very end of the program).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
timetypein 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_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
timetypein 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
- 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