since: 2.26

Declaration [src]

g_date_time_add_months (
  GDateTime* datetime,
  gint months

Description [src]

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

The day of the month of the resulting GDateTime is clamped to the number of days in the updated calendar month. For example, if adding 1 month to 31st January 2018, the result would be 28th February 2018. In 2020 (a leap year), the result would be 29th February.

Available since: 2.26



Type: gint

The number of months.

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.