mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* ext/date/date_strftime.c: removed unused code and arguments.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@31136 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
434157444f
commit
e48047fe0c
2 changed files with 12 additions and 45 deletions
|
@ -1,3 +1,7 @@
|
||||||
|
Sun Mar 20 22:32:30 2011 Tadayoshi Funaba <tadf@dotrb.org>
|
||||||
|
|
||||||
|
* ext/date/date_strftime.c: removed unused code and arguments.
|
||||||
|
|
||||||
Sun Mar 20 21:34:49 2011 Tadayoshi Funaba <tadf@dotrb.org>
|
Sun Mar 20 21:34:49 2011 Tadayoshi Funaba <tadf@dotrb.org>
|
||||||
|
|
||||||
* ext/date/date_core.c: replacement of implementation of
|
* ext/date/date_core.c: replacement of implementation of
|
||||||
|
|
|
@ -168,7 +168,8 @@ max(int a, int b)
|
||||||
/* strftime --- produce formatted time */
|
/* strftime --- produce formatted time */
|
||||||
|
|
||||||
static size_t
|
static size_t
|
||||||
date_strftime_with_timespec(char *s, size_t maxsize, const char *format, const struct vtm *vtm, VALUE timev, struct timespec *ts, int gmt)
|
date_strftime_wo_timespec(char *s, size_t maxsize, const char *format,
|
||||||
|
const struct vtm *vtm, VALUE timev)
|
||||||
{
|
{
|
||||||
char *endp = s + maxsize;
|
char *endp = s + maxsize;
|
||||||
char *start = s;
|
char *start = s;
|
||||||
|
@ -234,7 +235,7 @@ date_strftime_with_timespec(char *s, size_t maxsize, const char *format, const s
|
||||||
} while (0)
|
} while (0)
|
||||||
#define STRFTIME(fmt) \
|
#define STRFTIME(fmt) \
|
||||||
do { \
|
do { \
|
||||||
i = date_strftime_with_timespec(s, endp - s, (fmt), vtm, timev, ts, gmt); \
|
i = date_strftime_wo_timespec(s, endp - s, (fmt), vtm, timev); \
|
||||||
if (!i) return 0; \
|
if (!i) return 0; \
|
||||||
if (precision > i) {\
|
if (precision > i) {\
|
||||||
if (start + maxsize < s + precision) { \
|
if (start + maxsize < s + precision) { \
|
||||||
|
@ -418,14 +419,7 @@ date_strftime_with_timespec(char *s, size_t maxsize, const char *format, const s
|
||||||
|
|
||||||
case 's':
|
case 's':
|
||||||
SKIP_MODIFIER_EO;
|
SKIP_MODIFIER_EO;
|
||||||
if (ts) {
|
{
|
||||||
time_t sec = ts->tv_sec;
|
|
||||||
if (~(time_t)0 <= 0)
|
|
||||||
FMT('0', 1, PRI_TIMET_PREFIX"d", sec);
|
|
||||||
else
|
|
||||||
FMT('0', 1, PRI_TIMET_PREFIX"u", sec);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
VALUE sec = div(timev, INT2FIX(1));
|
VALUE sec = div(timev, INT2FIX(1));
|
||||||
FMTV('0', 1, "d", sec);
|
FMTV('0', 1, "d", sec);
|
||||||
}
|
}
|
||||||
|
@ -495,12 +489,7 @@ date_strftime_with_timespec(char *s, size_t maxsize, const char *format, const s
|
||||||
{
|
{
|
||||||
int aoff, hl, hw;
|
int aoff, hl, hw;
|
||||||
|
|
||||||
if (gmt) {
|
off = NUM2LONG(rb_funcall(vtm->utc_offset, rb_intern("round"), 0));
|
||||||
off = 0;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
off = NUM2LONG(rb_funcall(vtm->utc_offset, rb_intern("round"), 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
aoff = off;
|
aoff = off;
|
||||||
if (aoff < 0)
|
if (aoff < 0)
|
||||||
|
@ -593,11 +582,6 @@ date_strftime_with_timespec(char *s, size_t maxsize, const char *format, const s
|
||||||
flags &= ~(BIT_OF(UPPER)|BIT_OF(CHCASE));
|
flags &= ~(BIT_OF(UPPER)|BIT_OF(CHCASE));
|
||||||
flags |= BIT_OF(LOWER);
|
flags |= BIT_OF(LOWER);
|
||||||
}
|
}
|
||||||
if (gmt) {
|
|
||||||
i = 3;
|
|
||||||
tp = "UTC";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (vtm->zone == NULL)
|
if (vtm->zone == NULL)
|
||||||
tp = "";
|
tp = "";
|
||||||
else
|
else
|
||||||
|
@ -761,22 +745,7 @@ date_strftime_with_timespec(char *s, size_t maxsize, const char *format, const s
|
||||||
}
|
}
|
||||||
NEEDS(precision);
|
NEEDS(precision);
|
||||||
|
|
||||||
if (ts) {
|
{
|
||||||
long subsec = ts->tv_nsec;
|
|
||||||
if (9 < precision) {
|
|
||||||
snprintf(s, endp - s, "%09ld", subsec);
|
|
||||||
memset(s+9, '0', precision-9);
|
|
||||||
s += precision;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
int i;
|
|
||||||
for (i = 0; i < 9-precision; i++)
|
|
||||||
subsec /= 10;
|
|
||||||
snprintf(s, endp - s, "%0*ld", precision, subsec);
|
|
||||||
s += precision;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
VALUE subsec = mod(timev, INT2FIX(1));
|
VALUE subsec = mod(timev, INT2FIX(1));
|
||||||
int ww;
|
int ww;
|
||||||
long n;
|
long n;
|
||||||
|
@ -896,15 +865,9 @@ date_strftime_with_timespec(char *s, size_t maxsize, const char *format, const s
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
date_strftime(char *s, size_t maxsize, const char *format, const struct vtm *vtm, VALUE timev, int gmt)
|
date_strftime(char *s, size_t maxsize, const char *format, const struct vtm *vtm, VALUE timev)
|
||||||
{
|
{
|
||||||
return date_strftime_with_timespec(s, maxsize, format, vtm, timev, NULL, gmt);
|
return date_strftime_wo_timespec(s, maxsize, format, vtm, timev);
|
||||||
}
|
|
||||||
|
|
||||||
size_t
|
|
||||||
date_strftime_timespec(char *s, size_t maxsize, const char *format, const struct vtm *vtm, struct timespec *ts, int gmt)
|
|
||||||
{
|
|
||||||
return date_strftime_with_timespec(s, maxsize, format, vtm, Qnil, ts, gmt);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* isleap --- is a year a leap year? */
|
/* isleap --- is a year a leap year? */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue