~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/time.cc

  • Committer: Brian Aker
  • Date: 2008-10-06 06:47:29 UTC
  • Revision ID: brian@tangent.org-20081006064729-2i9mhjkzyvow9xsm
RemoveĀ uint.

Show diffs side-by-side

added added

removed removed

Lines of Context:
95
95
        next week is week 1.
96
96
*/
97
97
 
98
 
uint calc_week(DRIZZLE_TIME *l_time, uint week_behaviour, uint *year)
 
98
uint32_t calc_week(DRIZZLE_TIME *l_time, uint32_t week_behaviour, uint32_t *year)
99
99
{
100
 
  uint days;
 
100
  uint32_t days;
101
101
  ulong daynr=calc_daynr(l_time->year,l_time->month,l_time->day);
102
102
  ulong first_daynr=calc_daynr(l_time->year,1,1);
103
103
  bool monday_first= test(week_behaviour & WEEK_MONDAY_FIRST);
104
104
  bool week_year= test(week_behaviour & WEEK_YEAR);
105
105
  bool first_weekday= test(week_behaviour & WEEK_FIRST_WEEKDAY);
106
106
 
107
 
  uint weekday=calc_weekday(first_daynr, !monday_first);
 
107
  uint32_t weekday=calc_weekday(first_daynr, !monday_first);
108
108
  *year=l_time->year;
109
109
 
110
110
  if (l_time->month == 1 && l_time->day <= 7-weekday)
138
138
        /* Change a daynr to year, month and day */
139
139
        /* Daynr 0 is returned as date 00.00.00 */
140
140
 
141
 
void get_date_from_daynr(long daynr,uint *ret_year,uint *ret_month,
142
 
                         uint *ret_day)
 
141
void get_date_from_daynr(long daynr,uint32_t *ret_year,uint32_t *ret_month,
 
142
                         uint32_t *ret_day)
143
143
{
144
 
  uint year,temp,leap_day,day_of_year,days_in_year;
 
144
  uint32_t year,temp,leap_day,day_of_year,days_in_year;
145
145
  unsigned char *month_pos;
146
146
 
147
147
  if (daynr <= 365L || daynr >= 3652500)
217
217
*/
218
218
 
219
219
enum enum_drizzle_timestamp_type
220
 
str_to_datetime_with_warn(const char *str, uint length, DRIZZLE_TIME *l_time,
221
 
                          uint flags)
 
220
str_to_datetime_with_warn(const char *str, uint32_t length, DRIZZLE_TIME *l_time,
 
221
                          uint32_t flags)
222
222
{
223
223
  int was_cut;
224
224
  THD *thd= current_thd;
279
279
    See str_to_time() for more info.
280
280
*/
281
281
bool
282
 
str_to_time_with_warn(const char *str, uint length, DRIZZLE_TIME *l_time)
 
282
str_to_time_with_warn(const char *str, uint32_t length, DRIZZLE_TIME *l_time)
283
283
{
284
284
  int warning;
285
285
  bool ret_val= str_to_time(str, length, l_time, &warning);
349
349
*/
350
350
 
351
351
bool parse_date_time_format(enum enum_drizzle_timestamp_type format_type, 
352
 
                            const char *format, uint format_length,
 
352
                            const char *format, uint32_t format_length,
353
353
                            DATE_TIME_FORMAT *date_time_format)
354
354
{
355
 
  uint offset= 0, separators= 0;
 
355
  uint32_t offset= 0, separators= 0;
356
356
  const char *ptr= format, *format_str;
357
357
  const char *end= ptr+format_length;
358
358
  unsigned char *dt_pos= date_time_format->positions;
375
375
  {
376
376
    if (*ptr == '%' && ptr+1 != end)
377
377
    {
378
 
      uint position;
 
378
      uint32_t position;
379
379
      switch (*++ptr) {
380
380
      case 'y':                                 // Year
381
381
      case 'Y':
479
479
  if (dt_pos[6] != 255)                         // If fractional seconds
480
480
  {
481
481
    /* remove fractional seconds from later tests */
482
 
    uint pos= dt_pos[6] -1;
 
482
    uint32_t pos= dt_pos[6] -1;
483
483
    /* Remove separator before %f from sep map */
484
484
    separator_map= ((separator_map & ((ulong) (1 << pos)-1)) |
485
485
                    ((separator_map & ~((ulong) (1 << pos)-1)) >> 1));
581
581
 
582
582
DATE_TIME_FORMAT
583
583
*date_time_format_make(enum enum_drizzle_timestamp_type format_type,
584
 
                       const char *format_str, uint format_length)
 
584
                       const char *format_str, uint32_t format_length)
585
585
{
586
586
  DATE_TIME_FORMAT tmp;
587
587
 
689
689
void make_time(const DATE_TIME_FORMAT *format __attribute__((unused)),
690
690
               const DRIZZLE_TIME *l_time, String *str)
691
691
{
692
 
  uint length= (uint) my_time_to_str(l_time, (char*) str->ptr());
 
692
  uint32_t length= (uint) my_time_to_str(l_time, (char*) str->ptr());
693
693
  str->length(length);
694
694
  str->set_charset(&my_charset_bin);
695
695
}
698
698
void make_date(const DATE_TIME_FORMAT *format __attribute__((unused)),
699
699
               const DRIZZLE_TIME *l_time, String *str)
700
700
{
701
 
  uint length= (uint) my_date_to_str(l_time, (char*) str->ptr());
 
701
  uint32_t length= (uint) my_date_to_str(l_time, (char*) str->ptr());
702
702
  str->length(length);
703
703
  str->set_charset(&my_charset_bin);
704
704
}
707
707
void make_datetime(const DATE_TIME_FORMAT *format __attribute__((unused)),
708
708
                   const DRIZZLE_TIME *l_time, String *str)
709
709
{
710
 
  uint length= (uint) my_datetime_to_str(l_time, (char*) str->ptr());
 
710
  uint32_t length= (uint) my_datetime_to_str(l_time, (char*) str->ptr());
711
711
  str->length(length);
712
712
  str->set_charset(&my_charset_bin);
713
713
}
715
715
 
716
716
void make_truncated_value_warning(THD *thd, DRIZZLE_ERROR::enum_warning_level level,
717
717
                                  const char *str_val,
718
 
                                  uint str_length,
 
718
                                  uint32_t str_length,
719
719
                                  enum enum_drizzle_timestamp_type time_type,
720
720
                                  const char *field_name)
721
721
{