Re: gdate integration



Quoting Havoc Pennington (rhpennin@midway.uchicago.edu):

> +typedef enum {
> +  G_DATE_BAD_WEEKDAY  = 0,
> +  G_DATE_MONDAY	 = 1,
> +  G_DATE_TUESDAY	 = 2,
> +  G_DATE_WEDNESDAY	 = 3,
> +  G_DATE_THURSDAY	 = 4,
> +  G_DATE_FRIDAY	 = 5,
> +  G_DATE_SATURDAY	 = 6,
> +  G_DATE_SUNDAY	 = 7
> +} GDateWeekday;
> +typedef enum {
> +  G_DATE_BAD_MONTH = 0,
> +  G_DATE_JANUARY   = 1,
> +  G_DATE_FEBRUARY  = 2,
> +  G_DATE_MARCH     = 3,
> +  G_DATE_APRIL     = 4,
> +  G_DATE_MAY       = 5,
> +  G_DATE_JUNE      = 6,
> +  G_DATE_JULY      = 7,
> +  G_DATE_AUGUST    = 8,
> +  G_DATE_SEPTEMBER = 9,
> +  G_DATE_OCTOBER   = 10,
> +  G_DATE_NOVEMBER  = 11,
> +  G_DATE_DECEMBER  = 12
> +} GDateMonth;

Please use 0..6 for the valid days and -1 for the bad day. This way,
one can work with modulo on week days (well, more easily :-) OTOH,
months from 1 to 12 look more "natural" than from 0 to 11 :-/

> +/* If you add/sub months while day > 28, the day might change */
> +void 	g_date_add_months	     (GDate       *d,
> +					      guint	   nmonths);
> +void 	g_date_subtract_months	     (GDate       *d,
> +					      guint	   nmonths);
> +
> +/* If it's feb 29, changing years can move you to the 28th */
> +void 	g_date_add_years	     (GDate       *d,
> +					      guint	   nyears);
> +void 	g_date_subtract_years	     (GDate       *d,
> +					      guint	   nyears);

Thought about this for a while (whether it might be better to move
to mar, 1st than to feb 28th) but I don't know which is better.
Moving to the 28th means that you "add" 365 days (the normal length
of a year), moving to the 1st seems more "natural" (this is the
29th in the next year because it follows the 28th...). How are other
packages solving this ?

--
Dipl. Inf. (FH) Aaron "Optimizer" Digulla     Assistent im BIKS Labor, FB WI
"(to) optimize: Make a program faster by      FH Konstanz, Brauneggerstr. 55
improving the algorithms rather than by       Tel:+49-7531-206-514
buying a faster machine."                     EMail: digulla@fh-konstanz.de



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]