Soup.Date

Fields

Name

Type

Access

Description

day

int

r/w

day of the month, 1 to 31

hour

int

r/w

hour of the day, 0 to 23

minute

int

r/w

minute, 0 to 59

month

int

r/w

the month, 1 to 12

offset

int

r/w

offset from UTC

second

int

r/w

second, 0 to 59 (or up to 61 in the case of leap seconds)

utc

bool

r/w

True if the date is in UTC

year

int

r/w

the year, 1 to 9999

Methods

class

new (year, month, day, hour, minute, second)

class

new_from_now (offset_seconds)

class

new_from_string (date_string)

class

new_from_time_t (when)

copy ()

free ()

get_day ()

get_hour ()

get_minute ()

get_month ()

get_offset ()

get_second ()

get_utc ()

get_year ()

is_past ()

to_string (format)

to_time_t ()

to_timeval ()

Details

class Soup.Date

A date and time. The date is assumed to be in the (proleptic) Gregorian calendar. The time is in UTC if utc is True. Otherwise, the time is a local time, and offset gives the offset from UTC in minutes (such that adding offset to the time would give the correct UTC time). If utc is False and offset is 0, then the Soup.Date represents a “floating” time with no associated timezone information.

classmethod new(year, month, day, hour, minute, second)
Parameters:
  • year (int) – the year (1-9999)

  • month (int) – the month (1-12)

  • day (int) – the day of the month (1-31, as appropriate for month)

  • hour (int) – the hour (0-23)

  • minute (int) – the minute (0-59)

  • second (int) – the second (0-59, or up to 61 for leap seconds)

Returns:

a new Soup.Date

Return type:

Soup.Date

Creates a Soup.Date representing the indicated time, UTC.

classmethod new_from_now(offset_seconds)
Parameters:

offset_seconds (int) – offset from current time

Returns:

a new Soup.Date

Return type:

Soup.Date

Creates a Soup.Date representing a time offset_seconds after the current time (or before it, if offset_seconds is negative). If offset_seconds is 0, returns the current time.

If offset_seconds would indicate a time not expressible as a

time_t, the return value will be clamped into range.

classmethod new_from_string(date_string)
Parameters:

date_string (str) – the date in some plausible format

Returns:

a new Soup.Date, or None if date_string could not be parsed.

Return type:

Soup.Date or None

Parses date_string and tries to extract a date from it. This recognizes all of the “HTTP-date” formats from RFC 2616, all ISO 8601 formats containing both a time and a date, RFC 2822 dates, and reasonable approximations thereof. (Eg, it is lenient about whitespace, leading “0”s, etc.)

classmethod new_from_time_t(when)
Parameters:

when (int) – a time_t

Returns:

a new Soup.Date

Return type:

Soup.Date

Creates a Soup.Date corresponding to when

copy()
Return type:

Soup.Date

Copies self.

New in version 2.24.

free()

Frees self.

New in version 2.24.

get_day()
Returns:

self's day

Return type:

int

Gets self's day.

New in version 2.32.

get_hour()
Returns:

self's hour

Return type:

int

Gets self's hour.

New in version 2.32.

get_minute()
Returns:

self's minute

Return type:

int

Gets self's minute.

New in version 2.32.

get_month()
Returns:

self's month

Return type:

int

Gets self's month.

New in version 2.32.

get_offset()
Returns:

self's offset from UTC. If Soup.Date.get_utc() returns False but Soup.Date.get_offset() returns 0, that means the date is a “floating” time with no associated offset information.

Return type:

int

Gets self's offset from UTC.

New in version 2.32.

get_second()
Returns:

self's second

Return type:

int

Gets self's second.

New in version 2.32.

get_utc()
Returns:

True if self is UTC.

Return type:

int

Gets self's UTC flag

New in version 2.32.

get_year()
Returns:

self's year

Return type:

int

Gets self's year.

New in version 2.32.

is_past()
Returns:

True if self is in the past

Return type:

bool

Determines if self is in the past.

New in version 2.24.

to_string(format)
Parameters:

format (Soup.DateFormat) – the format to generate the date in

Returns:

self as a string

Return type:

str

Converts self to a string in the format described by format.

to_time_t()
Returns:

self as a time_t

Return type:

int

Converts self to a time_t, assumming it to be in UTC.

If self is not representable as a time_t, it will be clamped into range. (In particular, some HTTP cookies have expiration dates after “Y2.038k” (2038-01-19T03:14:07Z).)

to_timeval()
Returns:

a GLib.TimeVal structure in which to store the converted time.

Return type:

time: GLib.TimeVal

Converts self to a GLib.TimeVal.

New in version 2.24.

Deprecated since version ???: Do not use GLib.TimeVal, as it’s not Y2038-safe.