The R Project SVN R

Rev

Rev 59167 | Rev 64589 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 59167 Rev 59170
Line 213... Line 213...
213
w_strptime_internal (wchar_t *rp, const wchar_t *fmt, struct tm *tm,
213
w_strptime_internal (wchar_t *rp, const wchar_t *fmt, struct tm *tm,
214
		     enum locale_status *decided, double *psecs, 
214
		     enum locale_status *decided, double *psecs, 
215
		     int *poffset)
215
		     int *poffset)
216
{
216
{
217
    int cnt;
217
    int cnt;
218
    size_t val;
218
    int val;
219
    int have_I, is_pm;
219
    int have_I, is_pm;
220
    int century, want_century;
220
    int century, want_century;
221
    int have_wday, want_xday;
221
    int have_wday, want_xday;
222
    int have_yday;
222
    int have_yday;
223
    int have_mon, have_mday;
223
    int have_mon, have_mday;
Line 462... Line 462...
462
	case L'y':
462
	case L'y':
463
	    /* Match year within century.  */
463
	    /* Match year within century.  */
464
	    get_number (0, 99, 2);
464
	    get_number (0, 99, 2);
465
	    /* The "Year 2000: The Millennium Rollover" paper suggests that
465
	    /* The "Year 2000: The Millennium Rollover" paper suggests that
466
	       values in the range 69-99 refer to the twentieth century.  */
466
	       values in the range 69-99 refer to the twentieth century.  */
-
 
467
	    int ival = val;
467
	    tm->tm_year = val >= 69 ? val : val + 100;
468
	    tm->tm_year = ival >= 69 ? ival : ival + 100;
468
	    /* Indicate that we want to use the century, if specified.  */
469
	    /* Indicate that we want to use the century, if specified.  */
469
	    want_century = 1;
470
	    want_century = 1;
470
	    want_xday = 1;
471
	    want_xday = 1;
471
	    break;
472
	    break;
472
	case L'Y':
473
	case L'Y':
Line 492... Line 493...
492
		    /* We have to convert the minutes into decimal.  */
493
		    /* We have to convert the minutes into decimal.  */
493
		    if (val % 100 >= 60) return NULL;
494
		    if (val % 100 >= 60) return NULL;
494
		    val = (val / 100) * 100 + ((val % 100) * 50) / 30;
495
		    val = (val / 100) * 100 + ((val % 100) * 50) / 30;
495
		}
496
		}
496
		if (val > 1200) return NULL;
497
		if (val > 1200) return NULL;
497
		off = (val * 3600) / 100;
498
		off = ((val * 3600) / 100);
498
		if (neg) off = -off;
499
		if (neg) off = -off;
499
		*poffset = off;
500
		*poffset = off;
500
	    }
501
	    }
501
	    break;
502
	    break;
502
	case L'Z':
503
	case L'Z':
Line 517... Line 518...
517
	    {
518
	    {
518
	    case L'd':
519
	    case L'd':
519
	    case L'e':
520
	    case L'e':
520
		/* Match day of month using alternate numeric symbols.  */
521
		/* Match day of month using alternate numeric symbols.  */
521
		get_alt_number (1, 31, 2);
522
		get_alt_number (1, 31, 2);
522
		tm->tm_mday = val;
523
	        tm->tm_mday = val;
523
		have_mday = 1;
524
		have_mday = 1;
524
		want_xday = 1;
525
		want_xday = 1;
525
		break;
526
		break;
526
	    case L'H':
527
	    case L'H':
527
		/* Match hour in 24-hour clock using alternate numeric
528
		/* Match hour in 24-hour clock using alternate numeric
528
		   symbols.  */
529
		   symbols.  */
529
		get_alt_number (0, 23, 2);
530
		get_alt_number (0, 23, 2);
530
		tm->tm_hour = val;
531
	        tm->tm_hour = val;
531
		have_I = 0;
532
		have_I = 0;
532
		break;
533
		break;
533
	    case L'I':
534
	    case L'I':
534
		/* Match hour in 12-hour clock using alternate numeric
535
		/* Match hour in 12-hour clock using alternate numeric
535
		   symbols.  */
536
		   symbols.  */
536
		get_alt_number (1, 12, 2);
537
		get_alt_number (1, 12, 2);
537
		tm->tm_hour = val % 12;
538
	        tm->tm_hour = val % 12;
538
		have_I = 1;
539
		have_I = 1;
539
		break;
540
		break;
540
	    case L'm':
541
	    case L'm':
541
		/* Match month using alternate numeric symbols.  */
542
		/* Match month using alternate numeric symbols.  */
542
		get_alt_number (1, 12, 2);
543
		get_alt_number (1, 12, 2);
543
		tm->tm_mon = val - 1;
544
	        tm->tm_mon = val - 1;
544
		have_mon = 1;
545
		have_mon = 1;
545
		want_xday = 1;
546
		want_xday = 1;
546
		break;
547
		break;
547
	    case L'M':
548
	    case L'M':
548
		/* Match minutes using alternate numeric symbols.  */
549
		/* Match minutes using alternate numeric symbols.  */
549
		get_alt_number (0, 59, 2);
550
		get_alt_number (0, 59, 2);
550
		tm->tm_min = val;
551
	        tm->tm_min = val;
551
		break;
552
		break;
552
	    case L'S':
553
	    case L'S':
553
		/* Match seconds using alternate numeric symbols.
554
		/* Match seconds using alternate numeric symbols.
554
		get_alt_number (0, 61, 2); */
555
		get_alt_number (0, 61, 2); */
555
		{
556
		{
556
		    double sval;
557
		    double sval;
557
		    wchar_t *end;
558
		    wchar_t *end;
558
		    sval = wcstod(rp, &end);
559
		    sval = wcstod(rp, &end);
559
		    if( sval >= 0.0 && sval <= 61.0) {
560
		    if( sval >= 0.0 && sval <= 61.0) {
560
			tm->tm_sec = sval;
561
			tm->tm_sec = (int) sval;
561
			*psecs = sval;
562
			*psecs = sval;
562
		    }
563
		    }
563
		    rp = end;
564
		    rp = end;
564
		}
565
		}
565
	    break;
566
	    break;
Line 585... Line 586...
585
		have_wday = 1;
586
		have_wday = 1;
586
		break;
587
		break;
587
	    case L'y':
588
	    case L'y':
588
		/* Match year within century using alternate numeric symbols.  */
589
		/* Match year within century using alternate numeric symbols.  */
589
		get_alt_number (0, 99, 2);
590
		get_alt_number (0, 99, 2);
-
 
591
	        int ival = val;
590
		tm->tm_year = val >= 69 ? val : val + 100;
592
	        tm->tm_year = ival >= 69 ? ival : ival + 100;
591
		want_xday = 1;
593
		want_xday = 1;
592
		break;
594
		break;
593
	    default:
595
	    default:
594
		return NULL;
596
		return NULL;
595
	    }
597
	    }
Line 672... Line 674...
672
strptime_internal (const char *rp, const char *fmt, struct tm *tm,
674
strptime_internal (const char *rp, const char *fmt, struct tm *tm,
673
		   enum locale_status *decided, double *psecs,
675
		   enum locale_status *decided, double *psecs,
674
		   int *poffset)
676
		   int *poffset)
675
{
677
{
676
    int cnt;
678
    int cnt;
677
    size_t val;
679
    int val;
678
    int have_I, is_pm;
680
    int have_I, is_pm;
679
    int century, want_century;
681
    int century, want_century;
680
    int have_wday, want_xday;
682
    int have_wday, want_xday;
681
    int have_yday;
683
    int have_yday;
682
    int have_mon, have_mday;
684
    int have_mon, have_mday;
Line 924... Line 926...
924
	    /* The "Year 2000: The Millennium Rollover" paper suggests that
926
	    /* The "Year 2000: The Millennium Rollover" paper suggests that
925
	       values in the range 69-99 refer to the twentieth century.
927
	       values in the range 69-99 refer to the twentieth century.
926
	       And this is mandated by the POSIX 2001 standard, with a
928
	       And this is mandated by the POSIX 2001 standard, with a
927
	       caveat that it might change in future.
929
	       caveat that it might change in future.
928
	    */
930
	    */
-
 
931
	    int ival = val;
929
	    tm->tm_year = val >= 69 ? val : val + 100;
932
	    tm->tm_year = ival >= 69 ? ival : ival + 100;
930
	    /* Indicate that we want to use the century, if specified.  */
933
	    /* Indicate that we want to use the century, if specified.  */
931
	    want_century = 1;
934
	    want_century = 1;
932
	    want_xday = 1;
935
	    want_xday = 1;
933
	    break;
936
	    break;
934
	case 'Y':
937
	case 'Y':
Line 1018... Line 1021...
1018
		   {
1021
		   {
1019
		       double sval;
1022
		       double sval;
1020
		       char *end;
1023
		       char *end;
1021
		       sval = strtod(rp, &end);
1024
		       sval = strtod(rp, &end);
1022
		       if( sval >= 0.0 && sval <= 61.0) {
1025
		       if( sval >= 0.0 && sval <= 61.0) {
1023
			   tm->tm_sec = sval;
1026
			   tm->tm_sec = (int) sval;
1024
			   *psecs = sval;
1027
			   *psecs = sval;
1025
		       }
1028
		       }
1026
		       rp = end;
1029
		       rp = end;
1027
		   }
1030
		   }
1028
		break;
1031
		break;
Line 1048... Line 1051...
1048
		have_wday = 1;
1051
		have_wday = 1;
1049
		break;
1052
		break;
1050
	    case 'y':
1053
	    case 'y':
1051
		/* Match year within century using alternate numeric symbols.  */
1054
		/* Match year within century using alternate numeric symbols.  */
1052
		get_alt_number (0, 99, 2);
1055
		get_alt_number (0, 99, 2);
-
 
1056
		int ival = val;
1053
		tm->tm_year = val >= 69 ? val : val + 100;
1057
		tm->tm_year = ival >= 69 ? ival : ival + 100;
1054
		want_xday = 1;
1058
		want_xday = 1;
1055
		break;
1059
		break;
1056
	    default:
1060
	    default:
1057
		return NULL;
1061
		return NULL;
1058
	    }
1062
	    }