Commit 50d534fc authored by Richard Hult's avatar Richard Hult Committed by Richard Hult

Fix bug #157254.

2005-03-15  Richard Hult  <richard@imendio.com>

	Fix bug #157254.

	* libplanner/mrp-time.c: Add new (temporary) API and use it to
	improve performance a lot with large projects. Long term we should
	either switch to it completely or rename it.

	* src/planner-gantt-background.c: (gantt_background_draw):
	* src/planner-gantt-header.c: (gantt_header_init),
	(gantt_header_expose_event), (gantt_header_motion_notify_event):
	* src/planner-gantt-print.c: (print_time_header):
	* src/planner-scale-utils.c: (planner_scale_format_time):
	* src/planner-scale-utils.h:
	* src/planner-task-dialog.c: (task_dialog_update_schedule_label),
	(task_dialog_calendar_changed_cb): Use the new API.

	* tests/time-test.c: Remove obsolete test.
parent 59742a72
2005-03-15 Richard Hult <richard@imendio.com>
Fix bug #157254.
* libplanner/mrp-time.c: Add new (temporary) API and use it to
improve performance a lot with large projects. Long term we should
either switch to it completely or rename it.
* src/planner-gantt-background.c: (gantt_background_draw):
* src/planner-gantt-header.c: (gantt_header_init),
(gantt_header_expose_event), (gantt_header_motion_notify_event):
* src/planner-gantt-print.c: (print_time_header):
* src/planner-scale-utils.c: (planner_scale_format_time):
* src/planner-scale-utils.h:
* src/planner-task-dialog.c: (task_dialog_update_schedule_label),
(task_dialog_calendar_changed_cb): Use the new API.
* tests/time-test.c: Remove obsolete test.
2005-03-13 Richard Hult <richard@imendio.com>
* Release 0.13.
......
......@@ -131,101 +131,6 @@ mrproject
@Returns:
<!-- ##### FUNCTION mrp_param_spec_time ##### -->
<para>
</para>
@name:
@nick:
@blurb:
@flags:
@Returns:
<!-- ##### FUNCTION mrp_time_align_day ##### -->
<para>
</para>
@t:
@Returns:
<!-- ##### FUNCTION mrp_time_compose ##### -->
<para>
</para>
@year:
@month:
@day:
@hour:
@minute:
@second:
@Returns:
<!-- ##### FUNCTION mrp_time_day_name ##### -->
<para>
</para>
@t:
@Returns:
<!-- ##### FUNCTION mrp_time_day_of_week ##### -->
<para>
</para>
@t:
@Returns:
<!-- ##### FUNCTION mrp_time_debug_print ##### -->
<para>
</para>
@t:
<!-- ##### FUNCTION mrp_time_decompose ##### -->
<para>
</para>
@t:
@year:
@month:
@day:
@hour:
@minute:
@second:
@Returns:
<!-- ##### FUNCTION mrp_time_format ##### -->
<para>
</para>
@format:
@t:
@Returns:
<!-- ##### FUNCTION mrp_time_from_msdate_string ##### -->
<para>
</para>
@str:
@Returns:
<!-- ##### FUNCTION mrp_time_from_string ##### -->
<para>
</para>
@str:
@err:
@Returns:
<!-- ##### FUNCTION mrp_time_from_tm ##### -->
<para>
......@@ -234,38 +139,6 @@ mrproject
@tm:
@Returns:
<!-- ##### FUNCTION mrp_time_month_name ##### -->
<para>
</para>
@t:
@Returns:
<!-- ##### FUNCTION mrp_time_month_name_initial ##### -->
<para>
</para>
@t:
@Returns:
<!-- ##### FUNCTION mrp_time_to_string ##### -->
<para>
</para>
@t:
@Returns:
<!-- ##### FUNCTION mrp_time_week_number ##### -->
<para>
</para>
@t:
@Returns:
<!-- ##### MACRO textdomain ##### -->
<para>
......
......@@ -52,3 +52,144 @@ Represents the maximium value for #mrptime.
@Returns:
<!-- ##### FUNCTION mrp_time_compose ##### -->
<para>
</para>
@year:
@month:
@day:
@hour:
@minute:
@second:
@Returns:
<!-- ##### FUNCTION mrp_time_decompose ##### -->
<para>
</para>
@t:
@year:
@month:
@day:
@hour:
@minute:
@second:
@Returns:
<!-- ##### FUNCTION mrp_time_from_string ##### -->
<para>
</para>
@str:
@err:
@Returns:
<!-- ##### FUNCTION mrp_time_to_string ##### -->
<para>
</para>
@t:
@Returns:
<!-- ##### FUNCTION mrp_time_from_msdate_string ##### -->
<para>
</para>
@str:
@Returns:
<!-- ##### FUNCTION mrp_time_align_day ##### -->
<para>
</para>
@t:
@Returns:
<!-- ##### FUNCTION mrp_time_day_of_week ##### -->
<para>
</para>
@t:
@Returns:
<!-- ##### FUNCTION mrp_time_week_number ##### -->
<para>
</para>
@t:
@Returns:
<!-- ##### FUNCTION mrp_time_day_name ##### -->
<para>
</para>
@t:
@Returns:
<!-- ##### FUNCTION mrp_time_month_name ##### -->
<para>
</para>
@t:
@Returns:
<!-- ##### FUNCTION mrp_time_month_name_initial ##### -->
<para>
</para>
@t:
@Returns:
<!-- ##### FUNCTION mrp_time_format ##### -->
<para>
</para>
@format:
@t:
@Returns:
<!-- ##### FUNCTION mrp_time_debug_print ##### -->
<para>
</para>
@t:
<!-- ##### FUNCTION mrp_param_spec_time ##### -->
<para>
</para>
@name:
@nick:
@blurb:
@flags:
@Returns:
This diff is collapsed.
......@@ -35,9 +35,20 @@ typedef long mrptime;
#define MRP_TIME_MIN 0
#define MRP_TIME_MAX 2147483647
typedef enum {
MRP_TIME_UNIT_NONE,
MRP_TIME_UNIT_YEAR,
MRP_TIME_UNIT_HALFYEAR,
MRP_TIME_UNIT_QUARTER,
MRP_TIME_UNIT_MONTH,
MRP_TIME_UNIT_WEEK,
MRP_TIME_UNIT_DAY,
MRP_TIME_UNIT_HALFDAY,
MRP_TIME_UNIT_TWO_HOURS,
MRP_TIME_UNIT_HOUR
} MrpTimeUnit;
mrptime mrp_time_current_time (void);
struct tm * mrp_time_to_tm (mrptime t);
mrptime mrp_time_from_tm (struct tm *tm);
mrptime mrp_time_compose (gint year,
gint month,
gint day,
......@@ -56,6 +67,10 @@ mrptime mrp_time_from_string (const gchar *str,
gchar * mrp_time_to_string (mrptime t);
mrptime mrp_time_from_msdate_string (const gchar *str);
mrptime mrp_time_align_day (mrptime t);
mrptime mrp_time_align_prev (mrptime t,
MrpTimeUnit unit);
mrptime mrp_time_align_next (mrptime t,
MrpTimeUnit unit);
gint mrp_time_day_of_week (mrptime t);
gint mrp_time_week_number (mrptime t);
const gchar *mrp_time_day_name (mrptime t);
......@@ -70,4 +85,75 @@ GParamSpec * mrp_param_spec_time (const gchar *name,
const gchar *blurb,
GParamFlags flags);
/*
* New API here.
*/
typedef struct _MrpTime MrpTime;
MrpTime * mrp_time2_new (void);
void mrp_time2_free (MrpTime *t);
void mrp_time2_set_date (MrpTime *t,
gint year,
gint month,
gint day);
void mrp_time2_set_time (MrpTime *t,
gint hour,
gint min,
gint sec);
void mrp_time2_get_date (MrpTime *t,
gint *year,
gint *month,
gint *day);
void mrp_time2_get_time (MrpTime *t,
gint *hour,
gint *min,
gint *sec);
void mrp_time2_add_years (MrpTime *t,
gint years);
void mrp_time2_add_months (MrpTime *t,
gint months);
void mrp_time2_add_days (MrpTime *t,
gint days);
void mrp_time2_add_seconds (MrpTime *t,
gint64 secs);
void mrp_time2_add_minutes (MrpTime *t,
gint64 mins);
void mrp_time2_add_hours (MrpTime *t,
gint64 hours);
void mrp_time2_subtract_years (MrpTime *t,
gint years);
void mrp_time2_subtract_months (MrpTime *t,
gint months);
void mrp_time2_subtract_days (MrpTime *t,
gint days);
void mrp_time2_subtract_hours (MrpTime *t,
gint64 hours);
void mrp_time2_subtract_minutes (MrpTime *t,
gint64 mins);
void mrp_time2_subtract_seconds (MrpTime *t,
gint64 secs);
void mrp_time2_debug_print (MrpTime *t);
gboolean mrp_time2_set_from_string (MrpTime *t,
const gchar *str);
gchar * mrp_time2_to_string (MrpTime *t);
void mrp_time2_set_epoch (MrpTime *t,
time_t epoch);
time_t mrp_time2_get_epoch (MrpTime *t);
const gchar *mrp_time2_get_day_name (MrpTime *t);
const gchar *mrp_time2_get_month_name (MrpTime *t);
const gchar *mrp_time2_get_month_initial (MrpTime *t);
gint mrp_time2_get_week_number (MrpTime *t);
void mrp_time2_align_prev (MrpTime *t,
MrpTimeUnit unit);
void mrp_time2_align_next (MrpTime *t,
MrpTimeUnit unit);
void mrp_time2_copy (MrpTime *dst,
MrpTime *src);
void mrp_time2_clear (MrpTime *t);
gint mrp_time2_compare (MrpTime *t1,
MrpTime *t2);
#endif /* __MRP_TIME_H__ */
......@@ -601,7 +601,7 @@ gantt_background_draw (GnomeCanvasItem *item,
wx1 = priv->timeline * hscale;
gnome_canvas_w2c (item->canvas, wx1, 0, &cx1, NULL);
snap = cy1 - floor (cy1 / (double)DASH_LENGTH + 0.5) * DASH_LENGTH;
snap = cy1 - floor (cy1 / (double) DASH_LENGTH + 0.5) * DASH_LENGTH;
gdk_draw_line (drawable,
priv->timeline_gc,
......
......@@ -40,10 +40,10 @@ struct _PlannerGanttHeaderPriv {
PangoLayout *layout;
PlannerScaleUnit major_unit;
MrpTimeUnit major_unit;
PlannerScaleFormat major_format;
PlannerScaleUnit minor_unit;
MrpTimeUnit minor_unit;
PlannerScaleFormat minor_format;
gdouble hscale;
......@@ -255,8 +255,8 @@ gantt_header_init (PlannerGanttHeader *header)
priv->height = -1;
priv->width = -1;
priv->major_unit = PLANNER_SCALE_UNIT_MONTH;
priv->minor_unit = PLANNER_SCALE_UNIT_WEEK;
priv->major_unit = MRP_TIME_UNIT_MONTH;
priv->minor_unit = MRP_TIME_UNIT_WEEK;
priv->layout = gtk_widget_create_pango_layout (GTK_WIDGET (header),
NULL);
......@@ -561,11 +561,11 @@ gantt_header_expose_event (GtkWidget *widget,
/* Get the widths of major/minor ticks so that we know how wide to make
* the clip region.
*/
major_width = hscale * (planner_scale_time_next (t0, priv->major_unit) -
planner_scale_time_prev (t0, priv->major_unit));
major_width = hscale * (mrp_time_align_next (t0, priv->major_unit) -
mrp_time_align_prev (t0, priv->major_unit));
minor_width = hscale * (planner_scale_time_next (t0, priv->minor_unit) -
planner_scale_time_prev (t0, priv->minor_unit));
minor_width = hscale * (mrp_time_align_next (t0, priv->minor_unit) -
mrp_time_align_prev (t0, priv->minor_unit));
gc = gdk_gc_new (widget->window);
gdk_gc_copy (gc, widget->style->text_gc[GTK_STATE_NORMAL]);
......@@ -574,12 +574,12 @@ gantt_header_expose_event (GtkWidget *widget,
rect.height = height;
/* Draw the major scale. */
if (major_width < 2 || priv->major_unit == PLANNER_SCALE_UNIT_NONE) {
if (major_width < 2 || priv->major_unit == MRP_TIME_UNIT_NONE) {
/* Unless it's too thin to make sense. */
goto minor_ticks;
}
t = planner_scale_time_prev (t0, priv->major_unit);
t = mrp_time_align_prev (t0, priv->major_unit);
while (t <= t1) {
x = floor (t * hscale - priv->x1 + 0.5);
......@@ -607,18 +607,18 @@ gantt_header_expose_event (GtkWidget *widget,
2,
priv->layout);
t = planner_scale_time_next (t, priv->major_unit);
t = mrp_time_align_next (t, priv->major_unit);
}
minor_ticks:
/* Draw the minor scale. */
if (minor_width < 2 || priv->major_unit == PLANNER_SCALE_UNIT_NONE) {
if (minor_width < 2 || priv->major_unit == MRP_TIME_UNIT_NONE) {
/* Unless it's too thin to make sense. */
goto done;
}
t = planner_scale_time_prev (t0, priv->minor_unit);
t = mrp_time_align_prev (t0, priv->minor_unit);
while (t <= t1) {
x = floor (t * hscale - priv->x1 + 0.5);
......@@ -646,7 +646,7 @@ gantt_header_expose_event (GtkWidget *widget,
height / 2 + 2,
priv->layout);
t = planner_scale_time_next (t, priv->minor_unit);
t = mrp_time_align_next (t, priv->minor_unit);
}
done:
......@@ -662,19 +662,13 @@ gantt_header_motion_notify_event (GtkWidget *widget,
PlannerGanttHeader *header;
PlannerGanttHeaderPriv *priv;
mrptime t;
struct tm *tm;
char *str;
header = PLANNER_GANTT_HEADER (widget);
priv = header->priv;
t = floor ((priv->x1 + event->x) / priv->hscale + 0.5);
tm = mrp_time_to_tm (t);
str = g_strdup_printf ("%d %s %d",
tm->tm_mday,
mrp_time_month_name (t),
tm->tm_year + 1900);
str = mrp_time_format (_("%e %b %Y"), t);
if (!priv->date_hint || strcmp (str, priv->date_hint) != 0) {
g_signal_emit (widget, signals[DATE_HINT_CHANGED], 0, str);
......
......@@ -63,10 +63,10 @@ struct _PlannerGanttPrintData {
gint level;
PlannerScaleUnit major_unit;
MrpTimeUnit major_unit;
PlannerScaleFormat major_format;
PlannerScaleUnit minor_unit;
MrpTimeUnit minor_unit;
PlannerScaleFormat minor_format;
gdouble header_height;
......@@ -310,8 +310,8 @@ print_time_header (PlannerGanttPrintData *data,
x = x1;
y = data->row_height;
t = planner_scale_time_prev (start, data->major_unit);
width = (planner_scale_time_next (t, data->major_unit) - t) / data->f - data->job->x_pad / 2;
t = mrp_time_align_prev (start, data->major_unit);
width = (mrp_time_align_next (t, data->major_unit) - t) / data->f - data->job->x_pad / 2;
while (t <= finish) {
x = x1 + (t - start) / data->f;
......@@ -334,15 +334,15 @@ print_time_header (PlannerGanttPrintData *data,
g_free (str);
}
t = planner_scale_time_next (t, data->major_unit);
t = mrp_time_align_next (t, data->major_unit);
}
/* Minor scale. */
x = x1;
y = 2 * data->row_height;
t = planner_scale_time_prev (start, data->minor_unit);
width = (planner_scale_time_next (t, data->minor_unit) - t) / data->f - data->job->x_pad / 2;
t = mrp_time_align_prev (start, data->minor_unit);
width = (mrp_time_align_next (t, data->minor_unit) - t) / data->f - data->job->x_pad / 2;
while (t <= finish) {
x = x1 + (t - start) / data->f;
......@@ -365,7 +365,7 @@ print_time_header (PlannerGanttPrintData *data,
g_free (str);
}
t = planner_scale_time_next (t, data->minor_unit);
t = mrp_time_align_next (t, data->minor_unit);
}
}
......
/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
/*
* Copyright (C) 2005 Imendio AB
* Copyright (C) 2002 CodeFactory AB
* Copyright (C) 2002 Richard Hult <richard@imendio.com>
* Copyright (C) 2002 Mikael Hallendal <micke@imendio.com>
......@@ -33,331 +34,134 @@
static const PlannerScaleConf scale_conf[] = {
/* Major unit Major format Minor unit Minor format */
{ PLANNER_SCALE_UNIT_YEAR, PLANNER_SCALE_FORMAT_MEDIUM, PLANNER_SCALE_UNIT_HALFYEAR, PLANNER_SCALE_FORMAT_SHORT, WEEK },
{ MRP_TIME_UNIT_YEAR, PLANNER_SCALE_FORMAT_MEDIUM, MRP_TIME_UNIT_HALFYEAR, PLANNER_SCALE_FORMAT_SHORT, WEEK },
{ PLANNER_SCALE_UNIT_YEAR, PLANNER_SCALE_FORMAT_MEDIUM, PLANNER_SCALE_UNIT_HALFYEAR, PLANNER_SCALE_FORMAT_SHORT, WEEK },
{ PLANNER_SCALE_UNIT_YEAR, PLANNER_SCALE_FORMAT_MEDIUM, PLANNER_SCALE_UNIT_QUARTER, PLANNER_SCALE_FORMAT_SHORT, WEEK },
{ PLANNER_SCALE_UNIT_YEAR, PLANNER_SCALE_FORMAT_MEDIUM, PLANNER_SCALE_UNIT_QUARTER, PLANNER_SCALE_FORMAT_MEDIUM, WEEK },
{ MRP_TIME_UNIT_YEAR, PLANNER_SCALE_FORMAT_MEDIUM, MRP_TIME_UNIT_HALFYEAR, PLANNER_SCALE_FORMAT_SHORT, WEEK },
{ MRP_TIME_UNIT_YEAR, PLANNER_SCALE_FORMAT_MEDIUM, MRP_TIME_UNIT_QUARTER, PLANNER_SCALE_FORMAT_SHORT, WEEK },
{ MRP_TIME_UNIT_YEAR, PLANNER_SCALE_FORMAT_MEDIUM, MRP_TIME_UNIT_QUARTER, PLANNER_SCALE_FORMAT_MEDIUM, WEEK },
{ PLANNER_SCALE_UNIT_HALFYEAR, PLANNER_SCALE_FORMAT_LONG, PLANNER_SCALE_UNIT_MONTH, PLANNER_SCALE_FORMAT_LONG, WEEK },
{ MRP_TIME_UNIT_HALFYEAR, PLANNER_SCALE_FORMAT_LONG, MRP_TIME_UNIT_MONTH, PLANNER_SCALE_FORMAT_LONG, WEEK },
{ PLANNER_SCALE_UNIT_QUARTER, PLANNER_SCALE_FORMAT_LONG, PLANNER_SCALE_UNIT_MONTH, PLANNER_SCALE_FORMAT_MEDIUM, DAY },
{ MRP_TIME_UNIT_QUARTER, PLANNER_SCALE_FORMAT_LONG, MRP_TIME_UNIT_MONTH, PLANNER_SCALE_FORMAT_MEDIUM, DAY },
{ PLANNER_SCALE_UNIT_MONTH, PLANNER_SCALE_FORMAT_LONG, PLANNER_SCALE_UNIT_WEEK, PLANNER_SCALE_FORMAT_MEDIUM, DAY },
{ MRP_TIME_UNIT_MONTH, PLANNER_SCALE_FORMAT_LONG, MRP_TIME_UNIT_WEEK, PLANNER_SCALE_FORMAT_MEDIUM, DAY },
{ PLANNER_SCALE_UNIT_WEEK, PLANNER_SCALE_FORMAT_LONG, PLANNER_SCALE_UNIT_DAY, PLANNER_SCALE_FORMAT_SHORT, DAY },
{ PLANNER_SCALE_UNIT_WEEK, PLANNER_SCALE_FORMAT_LONG, PLANNER_SCALE_UNIT_DAY, PLANNER_SCALE_FORMAT_MEDIUM, HALFDAY },
{ MRP_TIME_UNIT_WEEK, PLANNER_SCALE_FORMAT_LONG, MRP_TIME_UNIT_DAY, PLANNER_SCALE_FORMAT_SHORT, DAY },
{ MRP_TIME_UNIT_WEEK, PLANNER_SCALE_FORMAT_LONG, MRP_TIME_UNIT_DAY, PLANNER_SCALE_FORMAT_MEDIUM, HALFDAY },
{ PLANNER_SCALE_UNIT_DAY, PLANNER_SCALE_FORMAT_LONG, PLANNER_SCALE_UNIT_HALFDAY, PLANNER_SCALE_FORMAT_MEDIUM, HALFDAY },
{ PLANNER_SCALE_UNIT_DAY, PLANNER_SCALE_FORMAT_LONG, PLANNER_SCALE_UNIT_HALFDAY, PLANNER_SCALE_FORMAT_MEDIUM, HOUR },
{ MRP_TIME_UNIT_DAY, PLANNER_SCALE_FORMAT_LONG, MRP_TIME_UNIT_HALFDAY, PLANNER_SCALE_FORMAT_MEDIUM, HALFDAY },
{ MRP_TIME_UNIT_DAY, PLANNER_SCALE_FORMAT_LONG, MRP_TIME_UNIT_HALFDAY, PLANNER_SCALE_FORMAT_MEDIUM, HOUR },
{ PLANNER_SCALE_UNIT_DAY, PLANNER_SCALE_FORMAT_LONG, PLANNER_SCALE_UNIT_TWO_HOURS, PLANNER_SCALE_FORMAT_MEDIUM, HOUR },
{ MRP_TIME_UNIT_DAY, PLANNER_SCALE_FORMAT_LONG, MRP_TIME_UNIT_TWO_HOURS, PLANNER_SCALE_FORMAT_MEDIUM, HOUR },
{ PLANNER_SCALE_UNIT_DAY, PLANNER_SCALE_FORMAT_LONG, PLANNER_SCALE_UNIT_HOUR, PLANNER_SCALE_FORMAT_MEDIUM, HOUR },
{ PLANNER_SCALE_UNIT_DAY, PLANNER_SCALE_FORMAT_LONG, PLANNER_SCALE_UNIT_HOUR, PLANNER_SCALE_FORMAT_MEDIUM, HOUR }
{ MRP_TIME_UNIT_DAY, PLANNER_SCALE_FORMAT_LONG, MRP_TIME_UNIT_HOUR, PLANNER_SCALE_FORMAT_MEDIUM, HOUR },
{ MRP_TIME_UNIT_DAY, PLANNER_SCALE_FORMAT_LONG, MRP_TIME_UNIT_HOUR, PLANNER_SCALE_FORMAT_MEDIUM, HOUR }
};
const PlannerScaleConf *planner_scale_conf = scale_conf;
mrptime
planner_scale_time_prev (mrptime t,
PlannerScaleUnit unit)
{
struct tm *tm;
tm = mrp_time_to_tm (t);
switch (unit) {
case PLANNER_SCALE_UNIT_HOUR:
tm->tm_min = 0;
tm->tm_sec = 0;
break;
case PLANNER_SCALE_UNIT_TWO_HOURS:
tm->tm_min = 0;
tm->tm_sec = 0;
tm->tm_hour -= 2 - tm->tm_hour % 2;
break;
case PLANNER_SCALE_UNIT_HALFDAY:
if (tm->tm_hour < 12) {
tm->tm_hour = 0;
} else {
tm->tm_hour = 12;
}
tm->tm_min = 0;
tm->tm_sec = 0;
break;
case PLANNER_SCALE_UNIT_DAY:
tm->tm_hour = 0;
tm->tm_min = 0;
tm->tm_sec = 0;
break;
case PLANNER_SCALE_UNIT_WEEK:
tm->tm_mday -= tm->tm_wday - START_OF_WEEK;
tm->tm_hour = 0;
tm->tm_min = 0;
tm->tm_sec = 0;
break;
case PLANNER_SCALE_UNIT_MONTH:
tm->tm_mday = 1;
tm->tm_hour = 0;
tm->tm_min = 0;
tm->tm_sec = 0;
break;
case PLANNER_SCALE_UNIT_QUARTER:
tm->tm_mday = 1;
tm->tm_hour = 0;
tm->tm_min = 0;
tm->tm_sec = 0;
if (tm->tm_mon >= 0 && tm->tm_mon <= 2) {
tm->tm_mon = 0;
}
else if (tm->tm_mon >= 3 && tm->tm_mon <= 5) {
tm->tm_mon = 3;
}
else if (tm->tm_mon >= 6 && tm->tm_mon <= 8) {
tm->tm_mon = 6;
}
else if (tm->tm_mon >= 9 && tm->tm_mon <= 11) {
tm->tm_mon = 9;
}
break;
case PLANNER_SCALE_UNIT_HALFYEAR:
if (tm->tm_mon <= 5) {
tm->tm_mon = 0;
} else {
tm->tm_mon = 6;
}
tm->tm_mday = 1;
tm->tm_hour = 0;
tm->tm_min = 0;
tm->tm_sec = 0;
break;
case PLANNER_SCALE_UNIT_YEAR:
tm->tm_mday = 1;
tm->tm_mon = 0;
tm->tm_hour = 0;
tm->tm_min = 0;
tm->tm_sec = 0;
break;
case PLANNER_SCALE_UNIT_NONE:
break;
default:
g_assert_not_reached ();
}
return mrp_time_from_tm (tm);
}
mrptime
planner_scale_time_next (mrptime t,
PlannerScaleUnit unit)
{
struct tm *tm;