[Feature #18033] Name a magic number
This commit is contained in:
parent
8c272f4481
commit
0a2f300a8a
Notes:
git
2022-12-16 13:53:20 +00:00
12
time.c
12
time.c
@ -2532,12 +2532,16 @@ time_init_parse(rb_execution_context_t *ec, VALUE time, VALUE str, VALUE zone)
|
|||||||
}
|
}
|
||||||
if (!NIL_P(subsec)) {
|
if (!NIL_P(subsec)) {
|
||||||
/* subseconds is the last using ndigits */
|
/* subseconds is the last using ndigits */
|
||||||
if (ndigits < 9) {
|
static const size_t TIME_SCALE_NUMDIGITS =
|
||||||
VALUE mul = rb_int_positive_pow(10, 9 - ndigits);
|
/* TIME_SCALE should be 10000... */
|
||||||
|
rb_strlen_lit(STRINGIZE(TIME_SCALE)) - 1;
|
||||||
|
|
||||||
|
if (ndigits < TIME_SCALE_NUMDIGITS) {
|
||||||
|
VALUE mul = rb_int_positive_pow(10, TIME_SCALE_NUMDIGITS - ndigits);
|
||||||
subsec = rb_int_mul(subsec, mul);
|
subsec = rb_int_mul(subsec, mul);
|
||||||
}
|
}
|
||||||
else if (ndigits > 9) {
|
else if (ndigits > TIME_SCALE_NUMDIGITS) {
|
||||||
VALUE num = rb_int_positive_pow(10, ndigits - 9);
|
VALUE num = rb_int_positive_pow(10, ndigits - TIME_SCALE_NUMDIGITS);
|
||||||
subsec = rb_rational_new(subsec, num);
|
subsec = rb_rational_new(subsec, num);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user