summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'time.c')
-rw-r--r--time.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/time.c b/time.c
index 95df85db93..c3bda3f6af 100644
--- a/time.c
+++ b/time.c
@@ -36,6 +36,7 @@
#include "internal/array.h"
#include "internal/hash.h"
#include "internal/compar.h"
+#include "internal/error.h"
#include "internal/numeric.h"
#include "internal/rational.h"
#include "internal/string.h"
@@ -564,8 +565,7 @@ NORETURN(static void num_exact_fail(VALUE v));
static void
num_exact_fail(VALUE v)
{
- rb_raise(rb_eTypeError, "can't convert %"PRIsVALUE" into an exact number",
- rb_obj_class(v));
+ rb_cant_convert(v, "an exact number");
}
static VALUE
@@ -746,6 +746,8 @@ get_tzname(int dst)
}
#endif
+static void ruby_reset_leap_second_info(void);
+
void
ruby_reset_timezone(const char *val)
{
@@ -981,7 +983,6 @@ zone_str(const char *zone)
{
const char *p;
int ascii_only = 1;
- VALUE str;
size_t len;
if (zone == NULL) {
@@ -997,18 +998,18 @@ zone_str(const char *zone)
}
len = p - zone;
if (ascii_only) {
- str = rb_usascii_str_new(zone, len);
+ return rb_enc_interned_str(zone, len, rb_usascii_encoding());
}
else {
#ifdef _WIN32
- str = rb_utf8_str_new(zone, len);
+ VALUE str = rb_utf8_str_new(zone, len);
/* until we move to UTF-8 on Windows completely */
str = rb_str_export_locale(str);
+ return rb_fstring(str);
#else
- str = rb_enc_str_new(zone, len, rb_locale_encoding());
+ return rb_enc_interned_str(zone, len, rb_locale_encoding());
#endif
}
- return rb_fstring(str);
}
static void
@@ -2923,8 +2924,7 @@ time_timespec(VALUE num, int interval)
t.tv_nsec = NUM2LONG(f);
}
else {
- rb_raise(rb_eTypeError, "can't convert %"PRIsVALUE" into %s",
- rb_obj_class(num), tstr);
+ rb_cant_convert(num, tstr);
}
}
return t;
@@ -3820,8 +3820,7 @@ time_to_i(VALUE time)
* {Epoch seconds}[rdoc-ref:Time@Epoch+Seconds];
* subseconds are included.
*
- * The stored value of +self+ is a
- * {Rational}[rdoc-ref:Rational@#method-i-to_f],
+ * The stored value of +self+ is a Rational,
* which means that the returned value may be approximate:
*
* Time.utc(1970, 1, 1, 0, 0, 0).to_f # => 0.0