jadtfmt 0.0.2 → 0.0.3
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.
- data/ext/jadtfmt.c +15 -7
- metadata +2 -2
data/ext/jadtfmt.c
CHANGED
@@ -15,12 +15,12 @@ __declspec(dllexport) void Init_jadtfmt();
|
|
15
15
|
#include "jadtfmt.h"
|
16
16
|
#include "jadtfmt_icu.h"
|
17
17
|
|
18
|
-
#define VERSION "0.0.
|
18
|
+
#define VERSION "0.0.3"
|
19
19
|
|
20
20
|
#define DEFAULT_INT(n) (NIL_P(n) ? 0 : NUM2INT(n))
|
21
21
|
|
22
22
|
static VALUE JapaneseDateFormat;
|
23
|
-
static VALUE
|
23
|
+
static VALUE pph_G, pph_N, pph_n, pph_E, pph_G_pattern, pph_N_pattern, pph_n_pattern, pph_E_pattern;
|
24
24
|
|
25
25
|
/* */
|
26
26
|
static VALUE jadtfmt_initialize(int argc, VALUE *argv, VALUE self) {
|
@@ -141,10 +141,10 @@ static VALUE jadtfmt_Time_jastrftime(VALUE self, VALUE format) {
|
|
141
141
|
Check_Type(format, T_STRING);
|
142
142
|
jadtfmt = rb_funcall(JapaneseDateFormat, rb_intern("new"), 0);
|
143
143
|
|
144
|
-
if (rb_funcall(format, rb_intern("include?"), 1,
|
145
|
-
rb_funcall(jadtfmt, rb_intern("apply_pattern"), 1,
|
144
|
+
if (rb_funcall(format, rb_intern("include?"), 1, pph_G)) {
|
145
|
+
rb_funcall(jadtfmt, rb_intern("apply_pattern"), 1, pph_G_pattern);
|
146
146
|
replace = rb_funcall(jadtfmt, rb_intern("format"), 1, self);
|
147
|
-
format = rb_funcall(format, rb_intern("gsub"), 2,
|
147
|
+
format = rb_funcall(format, rb_intern("gsub"), 2, pph_G, replace);
|
148
148
|
}
|
149
149
|
|
150
150
|
if (rb_funcall(format, rb_intern("include?"), 1, pph_N)) {
|
@@ -159,6 +159,12 @@ static VALUE jadtfmt_Time_jastrftime(VALUE self, VALUE format) {
|
|
159
159
|
format = rb_funcall(format, rb_intern("gsub"), 2, pph_n, replace);
|
160
160
|
}
|
161
161
|
|
162
|
+
if (rb_funcall(format, rb_intern("include?"), 1, pph_E)) {
|
163
|
+
rb_funcall(jadtfmt, rb_intern("apply_pattern"), 1, pph_E_pattern);
|
164
|
+
replace = rb_funcall(jadtfmt, rb_intern("format"), 1, self);
|
165
|
+
format = rb_funcall(format, rb_intern("gsub"), 2, pph_E, replace);
|
166
|
+
}
|
167
|
+
|
162
168
|
return rb_funcall(self, rb_intern("strftime"), 1, format);
|
163
169
|
}
|
164
170
|
|
@@ -189,10 +195,12 @@ void Init_jadtfmt() {
|
|
189
195
|
rb_define_method(rb_cTime, "jadtfmt", jadtfmt_Time_jadtfmt, 1);
|
190
196
|
rb_define_method(rb_cTime, "jastrftime", jadtfmt_Time_jastrftime, 1);
|
191
197
|
|
192
|
-
|
198
|
+
pph_G = rb_str_new2("%G");
|
193
199
|
pph_N = rb_str_new2("%N");
|
194
200
|
pph_n = rb_str_new2("%n");
|
195
|
-
|
201
|
+
pph_E = rb_str_new2("%E");
|
202
|
+
pph_G_pattern = rb_str_new2("G");
|
196
203
|
pph_N_pattern = rb_str_new2("yy");
|
197
204
|
pph_n_pattern = rb_str_new2("y");
|
205
|
+
pph_E_pattern = rb_str_new2("E");
|
198
206
|
}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jadtfmt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- winebarrel
|
@@ -28,7 +28,7 @@ files:
|
|
28
28
|
- ext/jadtfmt_icu.h
|
29
29
|
- ext/extconf.rb
|
30
30
|
has_rdoc: true
|
31
|
-
homepage: http://
|
31
|
+
homepage: http://jadtfmt.rubyforge.org
|
32
32
|
post_install_message:
|
33
33
|
rdoc_options:
|
34
34
|
- --title
|