~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/calendar.cc

  • Committer: Gustaf Thorslund
  • Date: 2010-11-02 09:28:14 UTC
  • mto: (1911.1.1 build) (1900.1.3 build)
  • mto: This revision was merged to the branch mainline in revision 1901.
  • Revision ID: gustaf@thorslund.org-20101102092814-aih84whrkf6925kc
Replaced macros with functions/templates. Part of blueprint:
  https://blueprints.edge.launchpad.net/drizzle/+spec/replace-macro-functions/

Show diffs side-by-side

added added

removed removed

Lines of Context:
53
53
 * Private utility macro for enabling a switch between
54
54
 * Gregorian and Julian leap year date arrays.
55
55
 */
56
 
#define __DAYS_IN_MONTH(y, c) (const uint32_t *) (IS_LEAP_YEAR((y),(c)) ? __leap_days_in_month : __normal_days_in_month)
57
 
#define __DAYS_TO_END_MONTH(y, c) (const uint32_t *) (IS_LEAP_YEAR((y),(c)) ? __leap_days_to_end_month : __normal_days_to_end_month)
 
56
inline static const uint32_t* days_in_month(uint32_t y, enum calendar c) 
 
57
{
 
58
  if (is_leap_year(y, c))
 
59
    return __leap_days_in_month;
 
60
  else
 
61
    return __normal_days_in_month;
 
62
}
 
63
 
 
64
inline static const uint32_t* days_to_end_month(uint32_t y, enum calendar c) 
 
65
{
 
66
  if (is_leap_year(y, c))
 
67
    return __leap_days_to_end_month;
 
68
  else
 
69
    return __normal_days_to_end_month;
 
70
}
58
71
 
59
72
 
60
73
/**
289
302
    return (day <= __normal_days_in_month[month - 1]);
290
303
  else
291
304
  {
292
 
    const uint32_t *p_months= __DAYS_IN_MONTH(year, (enum calendar) GREGORIAN);
 
305
    const uint32_t *p_months= days_in_month(year, (enum calendar) GREGORIAN);
293
306
    return (day <= p_months[1]);
294
307
  }
295
308
}
303
316
 */
304
317
uint32_t days_in_gregorian_year_month(uint32_t year, uint32_t month)
305
318
{
306
 
  const uint32_t *p_months= __DAYS_IN_MONTH(year, GREGORIAN);
 
319
  const uint32_t *p_months= days_in_month(year, GREGORIAN);
307
320
  return p_months[month - 1];
308
321
}
309
322