The R Project SVN R

Rev

Rev 83436 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 83436 Rev 83444
Line 324... Line 324...
324
		continue;
324
		continue;
325
	    case 's':
325
	    case 's':
326
	    {
326
	    {
327
		stm  tm = *t;
327
		stm  tm = *t;
328
		char buf[22]; // <= 19 digs + sign + terminator
328
		char buf[22]; // <= 19 digs + sign + terminator
329
		int_fast64_t mkt = R_mktime(&tm);
329
		int_fast64_t mkt = R_mktime(&tm); // we know -1 is valid tine
330
		(void) snprintf(buf, 22, "%lld", (long long) mkt);
330
		(void) snprintf(buf, 22, "%lld", (long long) mkt);
331
		pt = _add(buf, pt, ptlim);
331
		pt = _add(buf, pt, ptlim);
332
	    }
332
	    }
333
	    continue;
333
	    continue;
334
	    case 'T':
334
	    case 'T':
Line 415... Line 415...
415
		continue;
415
		continue;
416
	    case 'y':
416
	    case 'y':
417
		pt = _yconv(t->tm_year, TM_YEAR_BASE, 0, 1, pt, ptlim);
417
		pt = _yconv(t->tm_year, TM_YEAR_BASE, 0, 1, pt, ptlim);
418
		continue;
418
		continue;
419
	    case 'Y':
419
	    case 'Y':
420
		// Changed to agree wirh glibc
420
		// Changed to allow glibc's way (no padding)
421
//		pt = _yconv(t->tm_year, TM_YEAR_BASE, 1, 1, pt, ptlim);
421
//		pt = _yconv(t->tm_year, TM_YEAR_BASE, 1, 1, pt, ptlim);
422
	    {
422
	    {
423
		char buf[20] = "%";
423
		char buf[20] = "%";
424
		int year = TM_YEAR_BASE + t->tm_year;
424
		int year = TM_YEAR_BASE + t->tm_year;
425
		char *p = getenv("R_PAD_YEARS_BY_ZERO");
425
		char *p = getenv("R_PAD_YEARS_BY_ZERO");
426
		if (!p) p = "yes";
426
		if (!p) p = "yes";
427
		if( strcmp(p, "yes") == 0 && pad == '\0') {
427
		if( strcmp(p, "yes") == 0 && pad == '\0') {
428
		    pad = '0'; width = 4;
428
		    pad = '0'; width = 4;
429
		}
429
		}
430
		if (pad == '0' || pad == '+') strcat(buf, "0");
430
		if (pad == '0' || pad == '+') strcat(buf, "0");
-
 
431
		if (width > 0) {
-
 
432
		    size_t sz = strlen(buf);
431
		if (width > 0) sprintf(buf+strlen(buf), "%u", width);
433
		    snprintf(buf+sz, 20-sz, "%u", width);
-
 
434
		}
432
		if (pad == '+' && year > 9999) strcat(buf, "+");
435
		if (pad == '+' && year > 9999) strcat(buf, "+");
433
		strcat(buf, "d");
436
		strcat(buf, "d");
434
		pt = _conv(year, buf, pt, ptlim);
437
		pt = _conv(year, buf, pt, ptlim);
435
	    }
438
	    }
436
	    continue;
439
	    continue;