~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_time.cc

  • Committer: Brian Aker
  • Date: 2009-02-21 00:18:15 UTC
  • Revision ID: brian@tangent.org-20090221001815-x20e8h71e984lvs1
Completion (?) of uint conversion.

Show diffs side-by-side

added added

removed removed

Lines of Context:
201
201
       pos++)
202
202
    ;
203
203
 
204
 
  digits= (uint) (pos-str);
 
204
  digits= (uint32_t) (pos-str);
205
205
  start_loop= 0;                                /* Start of scan loop */
206
206
  date_len[format_position[0]]= 0;              /* Length of year field */
207
207
  if (pos == end || *pos == '.')
250
250
    2003-03-03 20:00:20 AM
251
251
    20:00:20.000000 AM 03-03-2000
252
252
  */
253
 
  i= cmax((uint) format_position[0], (uint) format_position[1]);
254
 
  set_if_bigger(i, (uint) format_position[2]);
 
253
  i= cmax((uint32_t) format_position[0], (uint32_t) format_position[1]);
 
254
  set_if_bigger(i, (uint32_t) format_position[2]);
255
255
  allow_space= ((1 << i) | (1 << format_position[6]));
256
256
  allow_space&= (1 | 2 | 4 | 8);
257
257
 
262
262
       i++)
263
263
  {
264
264
    const char *start= str;
265
 
    uint32_t tmp_value= (uint) (unsigned char) (*str++ - '0');
 
265
    uint32_t tmp_value= (uint32_t) (unsigned char) (*str++ - '0');
266
266
    while (str != end && my_isdigit(&my_charset_utf8_general_ci,str[0]) &&
267
267
           (!is_internal_format || --field_length))
268
268
    {
269
269
      tmp_value=tmp_value*10 + (uint32_t) (unsigned char) (*str - '0');
270
270
      str++;
271
271
    }
272
 
    date_len[i]= (uint) (str - start);
 
272
    date_len[i]= (uint32_t) (str - start);
273
273
    if (tmp_value > 999999)                     /* Impossible date part */
274
274
    {
275
275
      *was_cut= 1;
355
355
 
356
356
  if (!is_internal_format)
357
357
  {
358
 
    year_length= date_len[(uint) format_position[0]];
 
358
    year_length= date_len[(uint32_t) format_position[0]];
359
359
    if (!year_length)                           /* Year must be specified */
360
360
    {
361
361
      *was_cut= 1;
362
362
      return(DRIZZLE_TIMESTAMP_NONE);
363
363
    }
364
364
 
365
 
    l_time->year=               date[(uint) format_position[0]];
366
 
    l_time->month=              date[(uint) format_position[1]];
367
 
    l_time->day=                date[(uint) format_position[2]];
368
 
    l_time->hour=               date[(uint) format_position[3]];
369
 
    l_time->minute=             date[(uint) format_position[4]];
370
 
    l_time->second=             date[(uint) format_position[5]];
 
365
    l_time->year=               date[(uint32_t) format_position[0]];
 
366
    l_time->month=              date[(uint32_t) format_position[1]];
 
367
    l_time->day=                date[(uint32_t) format_position[2]];
 
368
    l_time->hour=               date[(uint32_t) format_position[3]];
 
369
    l_time->minute=             date[(uint32_t) format_position[4]];
 
370
    l_time->second=             date[(uint32_t) format_position[5]];
371
371
 
372
 
    frac_pos= (uint) format_position[6];
 
372
    frac_pos= (uint32_t) format_position[6];
373
373
    frac_len= date_len[frac_pos];
374
374
    if (frac_len < 6)
375
 
      date[frac_pos]*= (uint) log_10_int[6 - frac_len];
 
375
      date[frac_pos]*= (uint32_t) log_10_int[6 - frac_len];
376
376
    l_time->second_part= date[frac_pos];
377
377
 
378
378
    if (format_position[7] != (unsigned char) 255)
394
394
    l_time->minute=     date[4];
395
395
    l_time->second=     date[5];
396
396
    if (date_len[6] < 6)
397
 
      date[6]*= (uint) log_10_int[6 - date_len[6]];
 
397
      date[6]*= (uint32_t) log_10_int[6 - date_len[6]];
398
398
    l_time->second_part=date[6];
399
399
  }
400
400
  l_time->neg= 0;
520
520
    ;
521
521
 
522
522
  found_days=found_hours=0;
523
 
  if ((uint) (end-str) > 1 && str != end_of_days &&
 
523
  if ((uint32_t) (end-str) > 1 && str != end_of_days &&
524
524
      my_isdigit(&my_charset_utf8_general_ci, *str))
525
525
  {                                             /* Found days part */
526
526
    date[0]= (uint32_t) value;
577
577
  if ((end-str) >= 2 && *str == '.' && my_isdigit(&my_charset_utf8_general_ci,str[1]))
578
578
  {
579
579
    int field_length= 5;
580
 
    str++; value=(uint) (unsigned char) (*str - '0');
 
580
    str++; value=(uint32_t) (unsigned char) (*str - '0');
581
581
    while (++str != end && my_isdigit(&my_charset_utf8_general_ci, *str))
582
582
    {
583
583
      if (field_length-- > 0)
584
 
        value= value*10 + (uint) (unsigned char) (*str - '0');
 
584
        value= value*10 + (uint32_t) (unsigned char) (*str - '0');
585
585
    }
586
586
    if (field_length > 0)
587
587
      value*= (long) log_10_int[field_length];
712
712
  localtime_r(&seconds,&tm_tmp);
713
713
  l_time= &tm_tmp;
714
714
  my_time_zone=         3600;           /* Comp. for -3600 in my_gmt_sec */
715
 
  my_time.year=         (uint) l_time->tm_year+1900;
716
 
  my_time.month=        (uint) l_time->tm_mon+1;
717
 
  my_time.day=          (uint) l_time->tm_mday;
718
 
  my_time.hour=         (uint) l_time->tm_hour;
719
 
  my_time.minute=       (uint) l_time->tm_min;
720
 
  my_time.second=       (uint) l_time->tm_sec;
 
715
  my_time.year=         (uint32_t) l_time->tm_year+1900;
 
716
  my_time.month=        (uint32_t) l_time->tm_mon+1;
 
717
  my_time.day=          (uint32_t) l_time->tm_mday;
 
718
  my_time.hour=         (uint32_t) l_time->tm_hour;
 
719
  my_time.minute=       (uint32_t) l_time->tm_min;
 
720
  my_time.second=       (uint32_t) l_time->tm_sec;
721
721
  my_system_gmt_sec(&my_time, &my_time_zone, &not_used); /* Init my_time_zone */
722
722
}
723
723
 
869
869
  if ((t->year == TIMESTAMP_MAX_YEAR) && (t->month == 1) && (t->day > 4))
870
870
  {
871
871
    /*
872
 
      Below we will pass (uint) (t->day - shift) to calc_daynr.
 
872
      Below we will pass (uint32_t) (t->day - shift) to calc_daynr.
873
873
      As we don't want to get an overflow here, we will shift
874
874
      only safe dates. That's why we have (t->day > 4) above.
875
875
    */
906
906
  }
907
907
#endif
908
908
 
909
 
  tmp= (time_t) (((calc_daynr((uint) t->year, (uint) t->month, (uint) t->day) -
 
909
  tmp= (time_t) (((calc_daynr((uint32_t) t->year, (uint32_t) t->month, (uint32_t) t->day) -
910
910
                   (long) days_at_timestart)*86400L + (long) t->hour*3600L +
911
911
                  (long) (t->minute*60 + t->second)) + (time_t) my_time_zone -
912
912
                 3600);
916
916
  l_time=&tm_tmp;
917
917
  for (loop=0;
918
918
       loop < 2 &&
919
 
         (t->hour != (uint) l_time->tm_hour ||
920
 
          t->minute != (uint) l_time->tm_min ||
921
 
          t->second != (uint) l_time->tm_sec);
 
919
         (t->hour != (uint32_t) l_time->tm_hour ||
 
920
          t->minute != (uint32_t) l_time->tm_min ||
 
921
          t->second != (uint32_t) l_time->tm_sec);
922
922
       loop++)
923
923
  {                                     /* One check should be enough ? */
924
924
    /* Get difference in days */
945
945
    general time correction like it happened for Africa/Monrovia time zone
946
946
    in year 1972).
947
947
  */
948
 
  if (loop == 2 && t->hour != (uint) l_time->tm_hour)
 
948
  if (loop == 2 && t->hour != (uint32_t) l_time->tm_hour)
949
949
  {
950
950
    int days= t->day - l_time->tm_mday;
951
951
    if (days < -1)