Method

GLibDateTimeadd_years

since: 2.26

Declaration

GDateTime*
g_date_time_add_years (
  GDateTime* datetime,
  gint years
)

Description

Creates a copy of datetime and adds the specified number of years to the copy. Add negative values to subtract years.

As with g_date_time_add_months(), if the resulting date would be 29th February on a non-leap year, the day will be clamped to 28th February.

Available since: 2.26

Parameters

years

Type: gint

The number of years.

Return value

Type: GDateTime

The newly created GDateTime which should be freed with g_date_time_unref(), or NULL.

The caller of the method takes ownership of the data, and is responsible for freeing it.
The return value can be NULL.