JanaTime

JanaTime — A time representation interface

Functions

Types and Values

Object Hierarchy

    GBoxed
    ╰── JanaDuration
    GInterface
    ╰── JanaTime

Prerequisites

JanaTime requires GObject.

Description

JanaTime is the interface for representing a time. It has functions to set all the components of a basic calendar time, including date and timezone.

Functions

jana_time_get_seconds ()

guint8
jana_time_get_seconds (JanaTime *self);

Get the seconds component of the time. See jana_time_set_seconds().

Parameters

self

A JanaTime

 

Returns

The seconds component of the time.


jana_time_get_minutes ()

guint8
jana_time_get_minutes (JanaTime *self);

Get the minutes component of the time. See jana_time_set_minutes().

Parameters

self

A JanaTime

 

Returns

The minutes component of the time.


jana_time_get_hours ()

guint8
jana_time_get_hours (JanaTime *self);

Get the hours component of the time. See jana_time_set_hours().

Parameters

self

A JanaTime

 

Returns

The hours component of the time.


jana_time_get_day ()

guint8
jana_time_get_day (JanaTime *self);

Get the day component of the time. See jana_time_set_day().

Parameters

self

A JanaTime

 

Returns

The day component of the time.


jana_time_get_month ()

guint8
jana_time_get_month (JanaTime *self);

Get the month component of the time. See jana_time_set_month().

Parameters

self

A JanaTime

 

Returns

The month component of the time.


jana_time_get_year ()

guint16
jana_time_get_year (JanaTime *self);

Get the year component of the time. See jana_time_set_year().

Parameters

self

A JanaTime

 

Returns

The year component of the time.


jana_time_get_isdate ()

gboolean
jana_time_get_isdate (JanaTime *self);

Determines whether the time has been set as a date-only time. See jana_time_set_isdate().

Parameters

self

A JanaTime

 

Returns

TRUE if the time should be considered as a date, FALSE otherwise.


jana_time_get_daylight ()

gboolean
jana_time_get_daylight (JanaTime *self);

Determines whether the time is in daylight savings or not. See jana_time_set_daylight().

Parameters

self

A JanaTime

 

Returns

TRUE if the time is in daylight savings, FALSE otherwise.


jana_time_get_tzname ()

gchar *
jana_time_get_tzname (JanaTime *self);

Retrieves the timezone of the time. See jana_time_set_tzname().

Parameters

self

A JanaTime

 

Returns

The timezone name, e.g. "GMT/BST", "EST", etc.


jana_time_get_offset ()

glong
jana_time_get_offset (JanaTime *self);

Gets the UTC (Universal Time Co-ordinated) offset of the time, in seconds. See jana_time_set_offset().

Parameters

self

A JanaTime

 

Returns

The offset, in seconds, over UTC.


jana_time_set_seconds ()

void
jana_time_set_seconds (JanaTime *self,
                       gint seconds);

Sets the seconds component of the time. If the seconds parameter is invalid, the time will be normalised. For example, a seconds parameter of -1 would cause the minutes to be decreased by 1 and the seconds to be set to 59. If normalisation causes the time to cross the daylight savings boundary of the set timezone, the time will be adjusted accordingly.

Parameters

self

A JanaTime

 

seconds

The seconds component to set

 

jana_time_set_minutes ()

void
jana_time_set_minutes (JanaTime *self,
                       gint minutes);

Sets the minutes component of the time. If the minutes parameter is invalid, the time will be normalised. For example, a minutes parameter of -1 would cause the hours to be decreased by 1 and the minutes to be set to 59. If normalisation causes the time to cross the daylight savings boundary of the set timezone, the time will be adjusted accordingly.

Parameters

self

A JanaTime

 

minutes

The minutes component to set

 

jana_time_set_hours ()

void
jana_time_set_hours (JanaTime *self,
                     gint hours);

Sets the hours component of the time. If the hours parameter is invalid, the time will be normalised. For example, an hours parameter of -1 would cause the date to be decreased by 1 day and the hours to be set to 23. If normalisation causes the time to cross the daylight savings boundary of the set timezone, the time will be adjusted accordingly.

Parameters

self

A JanaTime

 

hours

The hours component to set

 

jana_time_set_day ()

void
jana_time_set_day (JanaTime *self,
                   gint day);

Sets the day component of the time. If the day parameter is invalid, the time will be normalised. For example, a day parameter of 0 would cause the date to be set to the last day of the previous month. If normalisation causes the time to cross the daylight savings boundary of the set timezone, the time will be adjusted accordingly.

Parameters

self

A JanaTime

 

day

The day component to set

 

jana_time_set_month ()

void
jana_time_set_month (JanaTime *self,
                     gint month);

Sets the month component of the time. If the day parameter is invalid, the time will be normalised. For example, a month parameter of 0 would cause the date to be set to the last month of the previous year. If normalisation causes the time to cross the daylight savings boundary of the set timezone, the time will be adjusted accordingly.

Parameters

self

A JanaTime

 

month

The month component to set

 

jana_time_set_year ()

void
jana_time_set_year (JanaTime *self,
                    gint year);

Sets the year component of the time. The time may be normalised in the situation that the year is adjusted from a leap year to a non-leap year and the month and day was set to the 29th of February. In this situation, the month and day would be adjusted to the 1st of March.

Parameters

self

A JanaTime

 

year

The year component to set

 

jana_time_set_isdate ()

void
jana_time_set_isdate (JanaTime *self,
                      gboolean isdate);

Sets whether the time should be considered only as a date. The seconds, minutes and hours components of the time are not guaranteed to be preserved when isdate is TRUE.

Parameters

self

A JanaTime

 

isdate

Whether the time should be considered only as a date

 

jana_time_set_tzname ()

void
jana_time_set_tzname (JanaTime *self,
                      const gchar *tzname);

Sets the timezone of the time. The time offset will also be adjusted to an offset that corresponds to the newly set timezone. If there is an offset for the newly set timezone that is the same as the previously set offset, the offset will remain unchanged. In addition, the time will be adjusted by the difference between the old offset and the new offset.

Parameters

self

A JanaTime

 

tzname

The timezone to set

 

jana_time_set_offset ()

void
jana_time_set_offset (JanaTime *self,
                      glong offset);

Sets the offset of the time. The timezone will also be adjusted to a zone that corresponds to the newly set offset. If there is a zone for the newly set offset that is the same as the previously set zone, the zone will remain unchanged. In addition, the time will be adjusted by the difference between the old offset and the new offset.

Parameters

self

A JanaTime

 

offset

The time offset to set

 

jana_time_duplicate ()

JanaTime *
jana_time_duplicate (JanaTime *self);

Creates a copy of self .

Parameters

self

A JanaTime

 

Returns

A new copy of self .


jana_duration_new ()

JanaDuration *
jana_duration_new (JanaTime *start,
                   JanaTime *end);

Creates a new JanaDuration.

Parameters

start

The start of the duration, or NULL

 

end

The end of the duration, or NULL

 

Returns

A newly allocated JanaDuration, to be freed with jana_duration_free().


jana_duration_copy ()

JanaDuration *
jana_duration_copy (JanaDuration *duration);

Create a copy of a JanaDuration.

Parameters

duration

A JanaDuration

 

Returns

A copy of duration .


jana_duration_set_start ()

void
jana_duration_set_start (JanaDuration *self,
                         JanaTime *start);

Sets the start of the duration.

Parameters

self

A JanaDuration

 

start

The start time, or NULL

 

jana_duration_set_end ()

void
jana_duration_set_end (JanaDuration *self,
                       JanaTime *end);

Sets the end of the duration.

Parameters

self

A JanaDuration

 

end

The end time, or NULL

 

jana_duration_valid ()

gboolean
jana_duration_valid (JanaDuration *self);

Determines whether the duration is valid. For the duration to be valid, the start and end must be set, and the end must occur on or after the start.

Parameters

self

A JanaDuration

 

Returns

TRUE if the duration is valid, FALSE otherwise.


jana_duration_free ()

void
jana_duration_free (JanaDuration *self);

Frees the memory associated with a JanaDuration.

Parameters

self

A JanaDuration

 

Types and Values

struct JanaDuration

struct JanaDuration {
	JanaTime *start;
	JanaTime *end;
};

This struct specifies a time period.

Members

JanaTime *start;

The start of the duration

 

JanaTime *end;

The end of the duration

 

JanaTime

typedef struct _JanaTime JanaTime;

The JanaTime struct contains only private data.