mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-28 01:56:52 +02:00
datetime: Allow setting fractionary seconds in new_full()
Otherwise we'll have to do: dt = g_date_time_new_full (Y, M, D, h, m, s, tz); tmp = g_date_time_add_usec (dt, usec); g_date_time_unref (dt); dt = tmp; With its additional allocations. https://bugzilla.gnome.org/show_bug.cgi?id=50076
This commit is contained in:
parent
67f1e52ce2
commit
0746f74036
@ -2111,7 +2111,7 @@ g_date_time_new_from_timeval (GTimeVal *tv)
|
|||||||
* @day: the day of the Gregorian month
|
* @day: the day of the Gregorian month
|
||||||
* @hour: the hour of the day
|
* @hour: the hour of the day
|
||||||
* @minute: the minute of the hour
|
* @minute: the minute of the hour
|
||||||
* @second: the second of the minute
|
* @second: the second of the minute, with eventual fractionary parts
|
||||||
* @time_zone: (allow-none): a #GTimeZone, or %NULL for UTC
|
* @time_zone: (allow-none): a #GTimeZone, or %NULL for UTC
|
||||||
*
|
*
|
||||||
* Creates a new #GDateTime using the date and times in the Gregorian
|
* Creates a new #GDateTime using the date and times in the Gregorian
|
||||||
@ -2130,14 +2130,14 @@ g_date_time_new_full (gint year,
|
|||||||
gint day,
|
gint day,
|
||||||
gint hour,
|
gint hour,
|
||||||
gint minute,
|
gint minute,
|
||||||
gint second,
|
gdouble second,
|
||||||
const GTimeZone *time_zone)
|
const GTimeZone *time_zone)
|
||||||
{
|
{
|
||||||
GDateTime *dt;
|
GDateTime *dt;
|
||||||
|
|
||||||
g_return_val_if_fail (hour >= 0 && hour < 24, NULL);
|
g_return_val_if_fail (hour >= 0 && hour < 24, NULL);
|
||||||
g_return_val_if_fail (minute >= 0 && minute < 60, NULL);
|
g_return_val_if_fail (minute >= 0 && minute < 60, NULL);
|
||||||
g_return_val_if_fail (second >= 0 && second <= 60, NULL);
|
g_return_val_if_fail (second >= 0.0 && second <= 60.0, NULL);
|
||||||
|
|
||||||
dt = g_date_time_new ();
|
dt = g_date_time_new ();
|
||||||
dt->days = date_to_proleptic_gregorian (year, month, day);
|
dt->days = date_to_proleptic_gregorian (year, month, day);
|
||||||
|
@ -116,7 +116,7 @@ GDateTime * g_date_time_new_full (gint year,
|
|||||||
gint day,
|
gint day,
|
||||||
gint hour,
|
gint hour,
|
||||||
gint minute,
|
gint minute,
|
||||||
gint second,
|
gdouble second,
|
||||||
const GTimeZone *time_zone);
|
const GTimeZone *time_zone);
|
||||||
|
|
||||||
GDateTime * g_date_time_ref (GDateTime *datetime);
|
GDateTime * g_date_time_ref (GDateTime *datetime);
|
||||||
|
@ -188,7 +188,6 @@ test_GDateTime_compare (void)
|
|||||||
dt2 = g_date_time_new_full (2000, 1, 1, 0, 0, 0, NULL);
|
dt2 = g_date_time_new_full (2000, 1, 1, 0, 0, 0, NULL);
|
||||||
g_assert_cmpint (0, ==, g_date_time_compare (dt1, dt2));
|
g_assert_cmpint (0, ==, g_date_time_compare (dt1, dt2));
|
||||||
g_date_time_unref (dt2);
|
g_date_time_unref (dt2);
|
||||||
|
|
||||||
g_date_time_unref (dt1);
|
g_date_time_unref (dt1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -391,6 +390,11 @@ test_GDateTime_get_millisecond (void)
|
|||||||
dt = g_date_time_new_from_timeval (&tv);
|
dt = g_date_time_new_from_timeval (&tv);
|
||||||
g_assert_cmpint ((tv.tv_usec / 1000), ==, g_date_time_get_millisecond (dt));
|
g_assert_cmpint ((tv.tv_usec / 1000), ==, g_date_time_get_millisecond (dt));
|
||||||
g_date_time_unref (dt);
|
g_date_time_unref (dt);
|
||||||
|
|
||||||
|
dt = g_date_time_new_full (2010, 9, 15, 12, 0, 0.1234, NULL);
|
||||||
|
g_assert_cmpint (123, ==, g_date_time_get_millisecond (dt));
|
||||||
|
g_assert_cmpint (123400, ==, g_date_time_get_microsecond (dt));
|
||||||
|
g_date_time_unref (dt);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user