mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
trivial changes
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35641 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
43d9f8972c
commit
c80308119b
1 changed files with 17 additions and 36 deletions
|
@ -7,18 +7,9 @@
|
||||||
#include "ruby/ruby.h"
|
#include "ruby/ruby.h"
|
||||||
#include "date_tmx.h"
|
#include "date_tmx.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
#if HAVE_SYS_TIME_H
|
|
||||||
#include <sys/time.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <math.h>
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
#undef strchr /* avoid AIX weirdness */
|
#undef strchr /* avoid AIX weirdness */
|
||||||
|
@ -174,7 +165,7 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
|
||||||
|
|
||||||
case 'B': /* full month name */
|
case 'B': /* full month name */
|
||||||
case 'b': /* abbreviated month name */
|
case 'b': /* abbreviated month name */
|
||||||
case 'h': /* abbreviated month name */
|
case 'h': /* same as %b */
|
||||||
if (flags & BIT_OF(CHCASE)) {
|
if (flags & BIT_OF(CHCASE)) {
|
||||||
flags &= ~(BIT_OF(LOWER)|BIT_OF(CHCASE));
|
flags &= ~(BIT_OF(LOWER)|BIT_OF(CHCASE));
|
||||||
flags |= BIT_OF(UPPER);
|
flags |= BIT_OF(UPPER);
|
||||||
|
@ -200,7 +191,7 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
|
||||||
STRFTIME("%a %b %e %H:%M:%S %Y");
|
STRFTIME("%a %b %e %H:%M:%S %Y");
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'D': /* date as %m/%d/%y */
|
case 'D':
|
||||||
STRFTIME("%m/%d/%y");
|
STRFTIME("%m/%d/%y");
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -210,7 +201,7 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
|
||||||
FMT((*format == 'd') ? '0' : ' ', 2, "d", v);
|
FMT((*format == 'd') ? '0' : ' ', 2, "d", v);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'F': /* Equivalent to %Y-%m-%d */
|
case 'F':
|
||||||
STRFTIME("%Y-%m-%d");
|
STRFTIME("%Y-%m-%d");
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -253,24 +244,14 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
|
||||||
FMT('0', 3, "d", v);
|
FMT('0', 3, "d", v);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'L':
|
case 'L': /* millisecond */
|
||||||
w = 3;
|
case 'N': /* nanosecond */
|
||||||
goto subsec;
|
if (*format == 'L')
|
||||||
|
w = 3;
|
||||||
case 'N':
|
else
|
||||||
/*
|
w = 9;
|
||||||
* fractional second digits. default is 9 digits
|
if (precision <= 0)
|
||||||
* (nanosecond).
|
|
||||||
*
|
|
||||||
* %3N millisecond (3 digits)
|
|
||||||
* %6N microsecond (6 digits)
|
|
||||||
* %9N nanosecond (9 digits)
|
|
||||||
*/
|
|
||||||
w = 9;
|
|
||||||
subsec:
|
|
||||||
if (precision <= 0) {
|
|
||||||
precision = w;
|
precision = w;
|
||||||
}
|
|
||||||
NEEDS(precision);
|
NEEDS(precision);
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -344,11 +325,11 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
|
||||||
FMTV('0', 1, "d", tmx_msecs);
|
FMTV('0', 1, "d", tmx_msecs);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'R': /* time as %H:%M */
|
case 'R':
|
||||||
STRFTIME("%H:%M");
|
STRFTIME("%H:%M");
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'r': /* time as %I:%M:%S %p */
|
case 'r':
|
||||||
STRFTIME("%I:%M:%S %p");
|
STRFTIME("%I:%M:%S %p");
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -361,7 +342,7 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
|
||||||
FMTV('0', 1, "d", tmx_secs);
|
FMTV('0', 1, "d", tmx_secs);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'T': /* time as %H:%M:%S */
|
case 'T':
|
||||||
STRFTIME("%H:%M:%S");
|
STRFTIME("%H:%M:%S");
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -382,7 +363,7 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
|
||||||
FMT('0', 2, "d", v);
|
FMT('0', 2, "d", v);
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
case 'v': /* date as dd-bbb-YYYY */
|
case 'v':
|
||||||
STRFTIME("%e-%b-%Y");
|
STRFTIME("%e-%b-%Y");
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -432,7 +413,7 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'z': /* time zone offset east of GMT e.g. -0600 */
|
case 'z': /* time zone offset east of UTC e.g. -0600 */
|
||||||
{
|
{
|
||||||
long off, aoff;
|
long off, aoff;
|
||||||
int hl, hw;
|
int hl, hw;
|
||||||
|
@ -618,8 +599,8 @@ date_strftime_with_tmx(char *s, size_t maxsize, const char *format,
|
||||||
if (*format == '\0') {
|
if (*format == '\0') {
|
||||||
*s = '\0';
|
*s = '\0';
|
||||||
return (s - start);
|
return (s - start);
|
||||||
} else
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue