## MrpTime

MrpTime — represents date and time.

## Functions

mrptime | mrp_time_current_time ()
mrptime | mrp_time_compose ()
gboolean | mrp_time_decompose ()
mrptime | mrp_time_from_string ()
gchar * | mrp_time_to_string ()
mrptime | mrp_time_align_day ()
mrptime | mrp_time_align_prev ()
mrptime | mrp_time_align_next ()
gint | mrp_time_day_of_week ()
gchar * | mrp_time_format ()
gchar * | mrp_time_format_locale ()
void | mrp_time_debug_print ()
GParamSpec * | mrp_param_spec_time ()

## Types and Values

typedef | mrptime
#define | MRP_TIME_INVALID
#define | MRP_TIME_MIN
#define | MRP_TIME_MAX
enum | MrpTimeUnit

## Includes

    #include <libplanner/mrp-time.h>

## Description

ISO 8601 representation is done in the basic format. Less separators are used: `20150101T000000Z` for `2015-01-01T00:00:00Z`.

## Functions

### mrp_time_current_time ()

    mrptime
    mrp_time_current_time (void);

Retrieves the current time as an mrptime value.

#### Returns

Current time.

### mrp_time_compose ()

    mrptime
    mrp_time_compose (gint year,
                      gint month,
                      gint day,
                      gint hour,
                      gint minute,
                      gint second);

Composes an mrptime value from the separate components.

#### Parameters

year | the year |
month | the month |
day | the day |
hour | the hour |
minute | the minute |
second | the second |

#### Returns

an mrptime value.

### mrp_time_decompose ()

    gboolean
    mrp_time_decompose (mrptime t,
                        gint *year,
                        gint *month,
                        gint *day,
                        gint *hour,
                        gint *minute,
                        gint *second);

Splits up an mrptime value into its components.

#### Parameters

t | an mrptime value to decompose |
year | location to store year, or `NULL` |
month | location to store month, or `NULL` |
day | location to store day, or `NULL` |
hour | location to store hour, or `NULL` |
minute | location to store minute, or `NULL` |
second | location to store second, or `NULL` |

#### Returns

`TRUE` on success.

### mrp_time_from_string ()

    mrptime
    mrp_time_from_string (const gchar *str);

Parses an ISO8601 time string and converts it to an mrptime.

#### Parameters

str | a string with a time, ISO8601 format |
err | Location to store error, or `NULL` |

#### Returns

Converted time value.

### mrp_time_to_string ()

    gchar *
    mrp_time_to_string (mrptime t);

Converts a time value to an ISO8601 string.

#### Parameters

t | an mrptime time |

#### Returns

Allocated string that needs to be freed.

### mrp_time_align_day ()

    mrptime
    mrp_time_align_day (mrptime t);

Aligns a time value to the start of the day.

#### Parameters

t | an mrptime value |

#### Returns

Aligned value.

### mrp_time_align_prev ()

    mrptime
    mrp_time_align_prev (mrptime t,
                         MrpTimeUnit unit);

Align `t` to the previous `unit` .

#### Parameters

t | an mrptime value |
unit | an MrpTimeUnit |

#### Returns

Aligned value.

### mrp_time_align_next ()

    mrptime
    mrp_time_align_next (mrptime t,
                         MrpTimeUnit unit);

Align `t` to the next `unit` .

#### Parameters

t | an mrptime value |
unit | an MrpTimeUnit |

#### Returns

Aligned value.

### mrp_time_day_of_week ()

    gint
    mrp_time_day_of_week (mrptime t);

Retrieves the day of week of the specified time.

#### Parameters

t | an mrptime value |

#### Returns

The day of week, in the range 0 to 6, where Sunday is 0.

### mrp_time_format ()

    gchar *
    mrp_time_format (const gchar *format,
                     mrptime t);

Formats a string with time values.

The allowed format codes are the same as for GDateTime.

#### Parameters

format | format string |
t | an mrptime value |

#### Returns

Newly created string that needs to be freed.

### mrp_time_format_locale ()

    gchar *
    mrp_time_format_locale (mrptime t);

Formats a string with time values. For format is the preferred for the current locale.

#### Parameters

t | an mrptime value |

#### Returns

Newly created string that needs to be freed.

### mrp_time_debug_print ()

    void
    mrp_time_debug_print (mrptime t);

Prints the time on stdout, for debugging purposes.

#### Parameters

t | an mrptime |

### mrp_param_spec_time ()

    GParamSpec *
    mrp_param_spec_time (const gchar *name,
                         const gchar *nick,
                         const gchar *blurb,
                         GParamFlags flags);

Convenience function for creating a GParamSpec carrying an mrptime value.

#### Parameters

name | name of the property |
nick | nick for the propery |
blurb | blurb for the property |
flags | flags |

#### Returns

Newly created GParamSpec.

## Types and Values

### mrptime

    typedef gint64 mrptime;

Number of seconds that have elapsed since 1970-01-01 00:00:00 UTC.

### MRP_TIME_INVALID

    #define MRP_TIME_INVALID G_GINT64_CONSTANT(0)

Represents an invalid mrptime value.

### MRP_TIME_MIN

    #define MRP_TIME_MIN G_GINT64_CONSTANT(0)

Represents the minimum value for mrptime.

### MRP_TIME_MAX

    #define MRP_TIME_MAX G_GINT64_CONSTANT(253402300799)

Represents the maximum value for mrptime.

### enum MrpTimeUnit

Time granularity meaningful to humans.

#### Members

MRP_TIME_UNIT_NONE | none. |
MRP_TIME_UNIT_YEAR | year. |
MRP_TIME_UNIT_HALFYEAR | half year. |
MRP_TIME_UNIT_QUARTER | quarter. |
MRP_TIME_UNIT_MONTH | month. |
MRP_TIME_UNIT_WEEK | week. |
MRP_TIME_UNIT_DAY | day. |
MRP_TIME_UNIT_HALFDAY | half day. |
MRP_TIME_UNIT_TWO_HOURS | two hours. |
MRP_TIME_UNIT_HOUR | hour. |