strptime 0.1.5-x86-mingw32 → 0.1.6-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6f7b1cb22183f2133bf2d0e389754afe22aed9e3
4
- data.tar.gz: 98d0ed4264aa2b9e5d66157278556188f7684b78
3
+ metadata.gz: e7d1e1c6d143a4c7e4fa6fdd5715b6f31262bcb7
4
+ data.tar.gz: 42e889d62689533f02d4edbc115f800464f91558
5
5
  SHA512:
6
- metadata.gz: a9e520a2d8cc939e87118849c8c16d83fd7236b43787df596da01170f7c5cbf3bf4dd6ba93b3e8495c8a01ab0ebf31431a082505c0b8330039ac4f62ee118b79
7
- data.tar.gz: 05bdaf14041a6d677246a933e85fadb2fc2547682ac827483c6f114366185fbc742fa5f18127f14f1029475cf672d81b56bd3f69ce09a11a96c359027af74e7b
6
+ metadata.gz: cccb521b2eece10f0f543464a918f71785b915b59048ce47592f0408a582aaf491ff50b82c118608fdcb6fb69e458b7390d128487b7f2de941bf309657d6c5c8
7
+ data.tar.gz: 39e04fa77536207aba071eab63f4e60b85a795f807857c0d09c04c94050510a00d0560502a69e3cbf8c4d19698a2de6bc221c809117e08e79f41c04fd9441b95
data/.travis.yml CHANGED
@@ -3,7 +3,7 @@ os:
3
3
  - linux
4
4
  - osx
5
5
  rvm:
6
- - 2.0.0-p647
6
+ - 2.0.0
7
7
  - 2.1
8
8
  - 2.2.3
9
9
  - 2.2.3-clang
data/appveyor.yml CHANGED
@@ -4,10 +4,8 @@ install:
4
4
  - ruby --version
5
5
  - gem --version
6
6
  - bundle install
7
- build: off
8
- test_script:
7
+ build_script:
9
8
  - bundle exec rake -rdevkit
10
-
11
9
  environment:
12
10
  matrix:
13
11
  - ruby_version: "200"
@@ -1,5 +1,6 @@
1
1
  require "mkmf"
2
2
 
3
- have_func 'timegm', 'time.h' or 'timegm(3) is required'
3
+ have_func('rb_timespec_now')
4
+ have_func('rb_time_timespec_new')
4
5
 
5
6
  create_makefile("strptime/strptime")
@@ -20,7 +20,8 @@
20
20
  typedef uint64_t WIDEVALUE;
21
21
  typedef WIDEVALUE wideval_t;
22
22
 
23
- #ifdef PACKED_STRUCT_UNALIGNED
23
+ #ifndef HAVE_RB_TIME_TIMESPEC_NEW
24
+ # if defined(PACKED_STRUCT_UNALIGNED) /* 2.2 */
24
25
  PACKED_STRUCT_UNALIGNED(struct vtm {
25
26
  VALUE year; /* 2000 for example. Integer. */
26
27
  VALUE subsecx; /* 0 <= subsecx < TIME_SCALE. possibly Rational. */
@@ -41,7 +42,7 @@ PACKED_STRUCT_UNALIGNED(struct time_object {
41
42
  uint8_t gmt : 3; /* 0:utc 1:localtime 2:fixoff 3:init */
42
43
  uint8_t tm_got : 1;
43
44
  });
44
- #else
45
+ # else /* 2.0.0~2.1 */
45
46
  struct vtm {
46
47
  VALUE year; /* 2000 for example. Integer. */
47
48
  int mon; /* 1..12 */
@@ -62,15 +63,13 @@ struct time_object {
62
63
  int gmt; /* 0:utc 1:localtime 2:fixoff */
63
64
  int tm_got;
64
65
  };
65
- #endif
66
+ # endif
66
67
 
67
68
  VALUE
68
- rb_time_succ(VALUE time);
69
- VALUE
70
- rbtime_timespec_new(const struct timespec *ts, int offset)
69
+ rb_time_timespec_new(const struct timespec *ts, int offset)
71
70
  {
72
71
  VALUE obj = rb_time_nano_new(ts->tv_sec, ts->tv_nsec);
73
- if (offset) {
72
+ if (-86400 < offset && offset < 86400) { /* fixoff */
74
73
  struct time_object *tobj;
75
74
  tobj = DATA_PTR(obj);
76
75
  tobj->tm_got = 0;
@@ -78,12 +77,25 @@ rbtime_timespec_new(const struct timespec *ts, int offset)
78
77
  tobj->vtm.utc_offset = INT2FIX(offset);
79
78
  tobj->vtm.zone = NULL;
80
79
  }
80
+ else if (offset == INT_MAX) { /* localtime */
81
+ }
82
+ else if (offset == INT_MAX-1) { /* UTC */
83
+ struct time_object *tobj;
84
+ tobj = DATA_PTR(obj);
85
+ tobj->tm_got = 0;
86
+ tobj->gmt = 1;
87
+ }
88
+ else {
89
+ rb_raise(rb_eArgError, "utc_offset out of range");
90
+ }
91
+
81
92
  return obj;
82
93
  }
94
+ #endif
83
95
 
84
- /* timespec_now */
96
+ #ifndef RB_TIMESPEC_NOW
85
97
  void
86
- timespec_now(struct timespec *ts)
98
+ rb_timespec_now(struct timespec *ts)
87
99
  {
88
100
  #ifdef HAVE_CLOCK_GETTIME
89
101
  if (clock_gettime(CLOCK_REALTIME, ts) == -1) {
@@ -100,6 +112,7 @@ timespec_now(struct timespec *ts)
100
112
  }
101
113
  #endif
102
114
  }
115
+ #endif
103
116
 
104
117
  /* localtime_with_gmtoff_zone */
105
118
  #ifdef HAVE_GMTIME_R
@@ -365,7 +365,7 @@ strptime_exec0(void **pc, const char *fmt, const char *str, size_t slen,
365
365
  const char *p0 = str + si;
366
366
  int r;
367
367
  size_t len;
368
- if (*p0 == 'z') {
368
+ if (*p0 == 'z' || *p0 == 'Z') {
369
369
  gmtoff = 0;
370
370
  ADD_PC(1);
371
371
  END_INSN(z)
@@ -420,9 +420,10 @@ strptime_exec0(void **pc, const char *fmt, const char *str, size_t slen,
420
420
  struct timespec ts;
421
421
  struct tm tm;
422
422
  time_t t;
423
+ int gmt = gmtoff >= INT_MAX-1 ? INT_MAX-gmtoff : 2;
423
424
 
424
425
  /* get current time with timezone */
425
- timespec_now(&ts);
426
+ rb_timespec_now(&ts);
426
427
  {
427
428
  static time_t ct;
428
429
  static struct tm ctm;
@@ -436,6 +437,9 @@ strptime_exec0(void **pc, const char *fmt, const char *str, size_t slen,
436
437
  if (gmtoff == INT_MAX) {
437
438
  gmtoff = localoff;
438
439
  }
440
+ else if (gmtoff == INT_MAX-1) {
441
+ gmtoff = 0;
442
+ }
439
443
  if (gmtoff != ctmoff) {
440
444
  tm_add_offset(&ctm, gmtoff - ctmoff);
441
445
  ctmoff = gmtoff;
@@ -469,7 +473,8 @@ strptime_exec0(void **pc, const char *fmt, const char *str, size_t slen,
469
473
  if (sec != -1) tm.tm_sec = sec;
470
474
  }
471
475
 
472
- t = timegm_noleapsecond(&tm) - gmtoff;
476
+ t = timegm_noleapsecond(&tm);
477
+ if (gmt != 1) t -= gmtoff;
473
478
  tsp->tv_sec = t;
474
479
  tsp->tv_nsec = nsec;
475
480
  *gmtoffp = gmtoff;
@@ -658,32 +663,6 @@ strptime_init_copy(VALUE copy, VALUE self)
658
663
  return copy;
659
664
  }
660
665
 
661
- typedef uint64_t WIDEVALUE;
662
- typedef WIDEVALUE wideval_t;
663
- #ifndef PACKED_STRUCT_UNALIGNED
664
- #define PACKED_STRUCT_UNALIGNED(x) x
665
- #endif
666
- PACKED_STRUCT_UNALIGNED(struct vtm {
667
- VALUE year; /* 2000 for example. Integer. */
668
- VALUE subsecx; /* 0 <= subsecx < TIME_SCALE. possibly Rational. */
669
- VALUE utc_offset; /* -3600 as -01:00 for example. possibly Rational. */
670
- const char *zone; /* "JST", "EST", "EDT", etc. */
671
- uint16_t yday : 9; /* 1..366 */
672
- uint8_t mon : 4; /* 1..12 */
673
- uint8_t mday : 5; /* 1..31 */
674
- uint8_t hour : 5; /* 0..23 */
675
- uint8_t min : 6; /* 0..59 */
676
- uint8_t sec : 6; /* 0..60 */
677
- uint8_t wday : 3; /* 0:Sunday, 1:Monday, ..., 6:Saturday 7:init */
678
- uint8_t isdst : 2; /* 0:StandardTime 1:DayLightSavingTime 3:init */
679
- });
680
- PACKED_STRUCT_UNALIGNED(struct time_object {
681
- wideval_t timew; /* time_t value * TIME_SCALE. possibly Rational. */
682
- struct vtm vtm;
683
- uint8_t gmt : 3; /* 0:utc 1:localtime 2:fixoff 3:init */
684
- uint8_t tm_got : 1;
685
- });
686
-
687
666
  /*
688
667
  * @overload exec(str)
689
668
  * @param str [String] string to parse
@@ -696,15 +675,15 @@ static VALUE
696
675
  strptime_exec(VALUE self, VALUE str)
697
676
  {
698
677
  struct strptime_object *tobj;
699
- int r, gmtoff = 0;
678
+ int r, gmtoff = INT_MAX;
679
+ struct timespec ts;
700
680
  StringValue(str);
701
681
  GetStrptimeval(self, tobj);
702
- struct timespec ts;
703
682
 
704
683
  r = strptime_exec0(tobj->isns, RSTRING_PTR(tobj->fmt), RSTRING_PTR(str),
705
684
  RSTRING_LEN(str), &ts, &gmtoff);
706
685
  if (r) rb_raise(rb_eArgError, "string doesn't match");
707
- return rbtime_timespec_new(&ts, gmtoff);
686
+ return rb_time_timespec_new(&ts, gmtoff);
708
687
  }
709
688
 
710
689
  /*
@@ -719,7 +698,7 @@ strptime_execi(VALUE self, VALUE str)
719
698
  {
720
699
  struct strptime_object *tobj;
721
700
  struct timespec ts;
722
- int r, gmtoff = 0;
701
+ int r, gmtoff = INT_MAX;
723
702
  StringValue(str);
724
703
  GetStrptimeval(self, tobj);
725
704
 
@@ -2,9 +2,13 @@
2
2
  #define STRPTIME_H 1
3
3
 
4
4
  #include "ruby.h"
5
- VALUE rbtime_timespec_new(const struct timespec *ts, int offset);
5
+ # ifndef HAVE_RB_TIME_TIMESPEC_NEW
6
+ VALUE rb_time_timespec_new(const struct timespec *ts, int offset);
7
+ # endif
6
8
  struct tm * localtime_with_gmtoff_zone(const time_t *t, struct tm *result, long *gmtoff, const char **zone);
7
- void timespec_now(struct timespec *ts);
9
+ # ifndef HAVE_RB_TIMESPEC_NOW
10
+ void rb_timespec_now(struct timespec *ts);
11
+ # endif
8
12
  time_t timegm_noleapsecond(struct tm *tm);
9
13
  void tm_add_offset(struct tm *tm, long diff);
10
14
 
Binary file
Binary file
Binary file
@@ -1,3 +1,3 @@
1
1
  class Strptime
2
- VERSION = "0.1.5"
2
+ VERSION = "0.1.6"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strptime
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: x86-mingw32
6
6
  authors:
7
7
  - NARUSE, Yui
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-05 00:00:00.000000000 Z
11
+ date: 2015-12-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler