~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to mysys/my_time.c

  • Committer: Monty Taylor
  • Date: 2008-09-13 20:24:20 UTC
  • mfrom: (383.1.35 drizzle)
  • Revision ID: monty@inaugust.com-20080913202420-lkj76ewbabl8ljvp
MergedĀ fromĀ trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
173
173
  *was_cut= 0;
174
174
 
175
175
  /* Skip space at start */
176
 
  for (; str != end && my_isspace(&my_charset_latin1, *str) ; str++)
 
176
  for (; str != end && my_isspace(&my_charset_utf8_general_ci, *str) ; str++)
177
177
    ;
178
 
  if (str == end || ! my_isdigit(&my_charset_latin1, *str))
 
178
  if (str == end || ! my_isdigit(&my_charset_utf8_general_ci, *str))
179
179
  {
180
180
    *was_cut= 1;
181
181
    return(DRIZZLE_TIMESTAMP_NONE);
191
191
    (YYYY-MM-DD,  YYYYMMDD, YYYYYMMDDHHMMSS)
192
192
  */
193
193
  for (pos=str;
194
 
       pos != end && (my_isdigit(&my_charset_latin1,*pos) || *pos == 'T');
 
194
       pos != end && (my_isdigit(&my_charset_utf8_general_ci,*pos) || *pos == 'T');
195
195
       pos++)
196
196
    ;
197
197
 
216
216
        We do this by checking if there is two numbers separated by
217
217
        space in the input.
218
218
      */
219
 
      while (pos < end && !my_isspace(&my_charset_latin1, *pos))
 
219
      while (pos < end && !my_isspace(&my_charset_utf8_general_ci, *pos))
220
220
        pos++;
221
 
      while (pos < end && !my_isdigit(&my_charset_latin1, *pos))
 
221
      while (pos < end && !my_isdigit(&my_charset_utf8_general_ci, *pos))
222
222
        pos++;
223
223
      if (pos == end)
224
224
      {
252
252
  not_zero_date= 0;
253
253
  for (i = start_loop;
254
254
       i < MAX_DATE_PARTS-1 && str != end &&
255
 
         my_isdigit(&my_charset_latin1,*str);
 
255
         my_isdigit(&my_charset_utf8_general_ci,*str);
256
256
       i++)
257
257
  {
258
258
    const char *start= str;
259
259
    uint32_t tmp_value= (uint) (uchar) (*str++ - '0');
260
 
    while (str != end && my_isdigit(&my_charset_latin1,str[0]) &&
 
260
    while (str != end && my_isdigit(&my_charset_utf8_general_ci,str[0]) &&
261
261
           (!is_internal_format || --field_length))
262
262
    {
263
263
      tmp_value=tmp_value*10 + (uint32_t) (uchar) (*str - '0');
296
296
      continue;
297
297
    }
298
298
    while (str != end &&
299
 
           (my_ispunct(&my_charset_latin1,*str) ||
300
 
            my_isspace(&my_charset_latin1,*str)))
 
299
           (my_ispunct(&my_charset_utf8_general_ci,*str) ||
 
300
            my_isspace(&my_charset_utf8_general_ci,*str)))
301
301
    {
302
 
      if (my_isspace(&my_charset_latin1,*str))
 
302
      if (my_isspace(&my_charset_utf8_general_ci,*str))
303
303
      {
304
304
        if (!(allow_space & (1 << i)))
305
305
        {
325
325
            continue;                           /* Not AM/PM */
326
326
          str+= 2;                              /* Skip AM/PM */
327
327
          /* Skip space after AM/PM */
328
 
          while (str != end && my_isspace(&my_charset_latin1,*str))
 
328
          while (str != end && my_isspace(&my_charset_utf8_general_ci,*str))
329
329
            str++;
330
330
        }
331
331
      }
406
406
    {
407
407
      for (; str != end ; str++)
408
408
      {
409
 
        if (!my_isspace(&my_charset_latin1, *str))
 
409
        if (!my_isspace(&my_charset_utf8_general_ci, *str))
410
410
        {
411
411
          not_zero_date= 1;                     /* Give warning */
412
412
          break;
425
425
 
426
426
  for (; str != end ; str++)
427
427
  {
428
 
    if (!my_isspace(&my_charset_latin1,*str))
 
428
    if (!my_isspace(&my_charset_utf8_general_ci,*str))
429
429
    {
430
430
      *was_cut= 1;
431
431
      break;
478
478
 
479
479
  l_time->neg=0;
480
480
  *warning= 0;
481
 
  for (; str != end && my_isspace(&my_charset_latin1,*str) ; str++)
 
481
  for (; str != end && my_isspace(&my_charset_utf8_general_ci,*str) ; str++)
482
482
    length--;
483
483
  if (str != end && *str == '-')
484
484
  {
505
505
  }
506
506
 
507
507
  /* Not a timestamp. Try to get this as a DAYS_TO_SECOND string */
508
 
  for (value=0; str != end && my_isdigit(&my_charset_latin1,*str) ; str++)
 
508
  for (value=0; str != end && my_isdigit(&my_charset_utf8_general_ci,*str) ; str++)
509
509
    value=value*10L + (long) (*str - '0');
510
510
 
511
511
  /* Skip all space after 'days' */
512
512
  end_of_days= str;
513
 
  for (; str != end && my_isspace(&my_charset_latin1, str[0]) ; str++)
 
513
  for (; str != end && my_isspace(&my_charset_utf8_general_ci, str[0]) ; str++)
514
514
    ;
515
515
 
516
516
  found_days=found_hours=0;
517
517
  if ((uint) (end-str) > 1 && str != end_of_days &&
518
 
      my_isdigit(&my_charset_latin1, *str))
 
518
      my_isdigit(&my_charset_utf8_general_ci, *str))
519
519
  {                                             /* Found days part */
520
520
    date[0]= (uint32_t) value;
521
521
    state= 1;                                   /* Assume next is hours */
522
522
    found_days= 1;
523
523
  }
524
524
  else if ((end-str) > 1 &&  *str == time_separator &&
525
 
           my_isdigit(&my_charset_latin1, str[1]))
 
525
           my_isdigit(&my_charset_utf8_general_ci, str[1]))
526
526
  {
527
527
    date[0]= 0;                                 /* Assume we found hours */
528
528
    date[1]= (uint32_t) value;
544
544
  /* Read hours, minutes and seconds */
545
545
  for (;;)
546
546
  {
547
 
    for (value=0; str != end && my_isdigit(&my_charset_latin1,*str) ; str++)
 
547
    for (value=0; str != end && my_isdigit(&my_charset_utf8_general_ci,*str) ; str++)
548
548
      value=value*10L + (long) (*str - '0');
549
549
    date[state++]= (uint32_t) value;
550
550
    if (state == 4 || (end-str) < 2 || *str != time_separator ||
551
 
        !my_isdigit(&my_charset_latin1,str[1]))
 
551
        !my_isdigit(&my_charset_utf8_general_ci,str[1]))
552
552
      break;
553
553
    str++;                                      /* Skip time_separator (':') */
554
554
  }
568
568
 
569
569
fractional:
570
570
  /* Get fractional second part */
571
 
  if ((end-str) >= 2 && *str == '.' && my_isdigit(&my_charset_latin1,str[1]))
 
571
  if ((end-str) >= 2 && *str == '.' && my_isdigit(&my_charset_utf8_general_ci,str[1]))
572
572
  {
573
573
    int field_length= 5;
574
574
    str++; value=(uint) (uchar) (*str - '0');
575
 
    while (++str != end && my_isdigit(&my_charset_latin1, *str))
 
575
    while (++str != end && my_isdigit(&my_charset_utf8_general_ci, *str))
576
576
    {
577
577
      if (field_length-- > 0)
578
578
        value= value*10 + (uint) (uchar) (*str - '0');
590
590
  /* (may occur as result of %g formatting of time value) */
591
591
  if ((end - str) > 1 &&
592
592
      (*str == 'e' || *str == 'E') &&
593
 
      (my_isdigit(&my_charset_latin1, str[1]) ||
 
593
      (my_isdigit(&my_charset_utf8_general_ci, str[1]) ||
594
594
       ((str[1] == '-' || str[1] == '+') &&
595
595
        (end - str) > 2 &&
596
 
        my_isdigit(&my_charset_latin1, str[2]))))
 
596
        my_isdigit(&my_charset_utf8_general_ci, str[2]))))
597
597
    return 1;
598
598
 
599
599
  if (internal_format_positions[7] != 255)
600
600
  {
601
601
    /* Read a possible AM/PM */
602
 
    while (str != end && my_isspace(&my_charset_latin1, *str))
 
602
    while (str != end && my_isspace(&my_charset_utf8_general_ci, *str))
603
603
      str++;
604
604
    if (str+2 <= end && (str[1] == 'M' || str[1] == 'm'))
605
605
    {
637
637
  {
638
638
    do
639
639
    {
640
 
      if (!my_isspace(&my_charset_latin1,*str))
 
640
      if (!my_isspace(&my_charset_utf8_general_ci,*str))
641
641
      {
642
642
        *warning|= DRIZZLE_TIME_WARN_TRUNCATED;
643
643
        break;