strptime 0.2.0.beta2 → 0.2.0.beta3
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 +4 -4
- data/ext/strptime/extconf.rb +1 -0
- data/ext/strptime/strftime.c +37 -4
- data/lib/strptime/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5888a6c2d53ab4cc5a55654bb8322cbefed4cd5e
|
4
|
+
data.tar.gz: d46348be35b99abe4b4fd90bf7f4b555598d6131
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b751a50b7a9a78ee862f1cd461fb3dc0e5ea1d5eb7e9a2ec18d783d94ee6b13cea9504c01987e0bd63543e471d8619c30718a434134d5d70d018c98ed6b13397
|
7
|
+
data.tar.gz: 96e23338cb997b45315a6dbaafd544c8d0045b6d9d1846398809fc889856668ae98844766f97905564085dfd449993a834a2c1f810007496414b4d0596353494
|
data/ext/strptime/extconf.rb
CHANGED
data/ext/strptime/strftime.c
CHANGED
@@ -3,6 +3,9 @@
|
|
3
3
|
#include <time.h>
|
4
4
|
|
5
5
|
VALUE rb_cStrftime;
|
6
|
+
#ifndef HAVE_RB_TIME_UTC_OFFSET
|
7
|
+
static ID id_gmtoff;
|
8
|
+
#endif
|
6
9
|
|
7
10
|
#define GetStrftimeval(obj, tobj) ((tobj) = get_strftimeval(obj))
|
8
11
|
#define GetNewStrftimeval(obj, tobj) ((tobj) = get_new_strftimeval(obj))
|
@@ -65,7 +68,7 @@ strftime_exec0(void **pc, VALUE fmt, struct timespec *tsp, int gmtoff, size_t re
|
|
65
68
|
LABEL_PTR(m), NULL, NULL, NULL,
|
66
69
|
NULL, NULL, NULL, NULL,
|
67
70
|
NULL, NULL, NULL, NULL,
|
68
|
-
LABEL_PTR(y),
|
71
|
+
LABEL_PTR(y), LABEL_PTR(z),
|
69
72
|
};
|
70
73
|
*pc = (void *)insns_address_table;
|
71
74
|
return Qnil;
|
@@ -163,6 +166,26 @@ strftime_exec0(void **pc, VALUE fmt, struct timespec *tsp, int gmtoff, size_t re
|
|
163
166
|
ADD_PC(1);
|
164
167
|
END_INSN(y)
|
165
168
|
}
|
169
|
+
INSN_ENTRY(z)
|
170
|
+
{
|
171
|
+
int h, m, tmp=gmtoff;
|
172
|
+
if (gmtoff >= 0) {
|
173
|
+
*p++ = '+';
|
174
|
+
} else {
|
175
|
+
*p++ = '-';
|
176
|
+
tmp = -tmp;
|
177
|
+
}
|
178
|
+
tmp /= 60;
|
179
|
+
h = (tmp / 60)&15; /* ignore too large offset */
|
180
|
+
m = tmp % 60;
|
181
|
+
*p++ = '0' + (h / 10);
|
182
|
+
*p++ = '0' + (h % 10);
|
183
|
+
*p++ = ':';
|
184
|
+
*p++ = '0' + (m / 10);
|
185
|
+
*p++ = '0' + (m % 10);
|
186
|
+
ADD_PC(1);
|
187
|
+
END_INSN(y)
|
188
|
+
}
|
166
189
|
INSN_ENTRY(_60)
|
167
190
|
{
|
168
191
|
size_t v = (size_t)GET_OPERAND(1);
|
@@ -233,6 +256,10 @@ strftime_compile(const char *fmt, size_t flen, size_t *rlenp)
|
|
233
256
|
goto accept_format;
|
234
257
|
case 'y':
|
235
258
|
rlen += 2;
|
259
|
+
goto accept_format;
|
260
|
+
case 'z':
|
261
|
+
rlen += 6;
|
262
|
+
goto accept_format;
|
236
263
|
accept_format:
|
237
264
|
tmp = insns_address_table[c - 'A'];
|
238
265
|
if (tmp) {
|
@@ -388,11 +415,16 @@ strftime_init_copy(VALUE copy, VALUE self)
|
|
388
415
|
static VALUE
|
389
416
|
strftime_exec(VALUE self, VALUE time)
|
390
417
|
{
|
391
|
-
struct strftime_object *
|
418
|
+
struct strftime_object *sobj;
|
392
419
|
struct timespec ts = rb_time_timespec(time);
|
393
|
-
|
420
|
+
#ifdef HAVE_RB_TIME_UTC_OFFSET
|
421
|
+
int gmtoff = FIX2INT(rb_time_utc_offset(time));
|
422
|
+
#else
|
423
|
+
int gmtoff = NUM2INT(rb_funcall(time, id_gmtoff, 0));
|
424
|
+
#endif
|
425
|
+
GetStrftimeval(self, sobj);
|
394
426
|
|
395
|
-
return strftime_exec0(
|
427
|
+
return strftime_exec0(sobj->isns, sobj->fmt, &ts, gmtoff, sobj->result_length);
|
396
428
|
}
|
397
429
|
|
398
430
|
/*
|
@@ -459,4 +491,5 @@ Init_strftime(void)
|
|
459
491
|
rb_define_method(rb_cStrftime, "exec", strftime_exec, 1);
|
460
492
|
rb_define_method(rb_cStrftime, "execi", strftime_execi, 1);
|
461
493
|
rb_define_method(rb_cStrftime, "source", strftime_source, 0);
|
494
|
+
id_gmtoff = rb_intern("gmtoff");
|
462
495
|
}
|
data/lib/strptime/version.rb
CHANGED
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.2.0.
|
4
|
+
version: 0.2.0.beta3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- NARUSE, Yui
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-11
|
11
|
+
date: 2017-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|