teptris 0.2.48 → 0.2.49

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6c1158decbe9ec09fbae4504a660b409d0d3b082d56c4afc232228b3fe09f6ba
4
- data.tar.gz: feb5d4823c5b238ca40565048f4445772a02e05148de97ef6f988a5c64d6d1cc
3
+ metadata.gz: b6cebca031f6e3c203926fd5192caa04650d41fb5726fd0989f41b9639c45e7f
4
+ data.tar.gz: 044e2bb206121f34bb5b10a461055e1cbde5ed37316d289727d9c6f90f66af9c
5
5
  SHA512:
6
- metadata.gz: e3bd532ee7bf75cfd4bf214be2960bf369c7cc4ad804362ee2f037ae1d1ad0a569691ba903240fda70066d1cf0d601a78a29e08f9dc8176ddb4f39341164eed4
7
- data.tar.gz: 9f0a8037043b602f41b4272f30419ecda8e64f05bb40fa8d27cb27c4d543339194098906e5429d3bb53de17e399141afcf88f6c116fb24d8d4f6cc59e3265c31
6
+ metadata.gz: 01c9f38cb3eb9048ecd662892b1715d7762a37f41f9a4f0159ab692edb781a8af378afa62cd00df477ce8a2d67b7ae1b08387222a7765817dabbafb013deb1d4
7
+ data.tar.gz: fa7e42685c337bfaad7f62ac46cc1dfb6b8a85cced308645e08c20e36b8c9667ee98adf07f44b30091541a809dd6a5e305b72d31032c501603306f532e2af883
@@ -41,11 +41,16 @@ static VALUE time_from_dt(const teptris_datetime *d, bool has_offset) {
41
41
  }
42
42
  return rb_time_num_new(num, INT2FIX(d->offset_seconds));
43
43
  }
44
+ /* whole seconds skip the Rational: Time.local normalizes
45
+ * Rational(s * 1e9, 1e9) to exactly s, so an Integer is the same
46
+ * result without the allocation or the rational path */
47
+ VALUE sec = (d->nanosecond != 0)
48
+ ? rb_Rational(LL2NUM((int64_t)d->second * 1000000000 +
49
+ d->nanosecond),
50
+ LL2NUM(1000000000))
51
+ : INT2FIX(d->second);
44
52
  VALUE args[6] = {INT2FIX(d->year), INT2FIX(d->month), INT2FIX(d->day),
45
- INT2FIX(d->hour), INT2FIX(d->minute),
46
- rb_Rational(LL2NUM((int64_t)d->second * 1000000000 +
47
- d->nanosecond),
48
- LL2NUM(1000000000))};
53
+ INT2FIX(d->hour), INT2FIX(d->minute), sec};
49
54
  return rb_funcallv(rb_cTime, rb_intern("local"), 6, args);
50
55
  }
51
56
 
@@ -1,3 +1,3 @@
1
1
  module Teptris
2
- VERSION = "0.2.48"
2
+ VERSION = "0.2.49"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teptris
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.48
4
+ version: 0.2.49
5
5
  platform: ruby
6
6
  authors:
7
7
  - teptris contributors