summaryrefslogtreecommitdiff
path: root/time.c
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-07 07:03:23 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2019-01-07 07:03:23 +0000
commit8371a9a4ceea32f8e76f3d867722b42e5477fba1 (patch)
tree60b5cb478a171209fbd859440d75a5ec5851ce05 /time.c
parent4f9ab3a01a475f5236632575fa4d3a6b6aef7d15 (diff)
downloadbundler-8371a9a4ceea32f8e76f3d867722b42e5477fba1.tar.gz
time.c: support military time zone names
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@66747 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'time.c')
-rw-r--r--time.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/time.c b/time.c
index 96a657e41d..a9bd2e8606 100644
--- a/time.c
+++ b/time.c
@@ -2066,9 +2066,21 @@ utc_offset_arg(VALUE arg)
if (s[0] == 'Z') {
return UTC_ZONE;
}
+ /* Military Time Zone Names */
+ if (s[0] >= 'A' && s[0] <= 'I') {
+ n = (int)s[0] - 'A' + 1;
+ }
+ else if (s[0] >= 'K' && s[0] <= 'M') {
+ n = (int)s[0] - 'A';
+ }
+ else if (s[0] >= 'N' && s[0] <= 'Y') {
+ n = 'M' - (int)s[0];
+ }
else {
goto invalid_utc_offset;
}
+ n *= 3600;
+ return INT2FIX(n);
case 3:
if (STRNCASECMP("UTC", s, 3) == 0) {
return UTC_ZONE;
@@ -2356,6 +2368,7 @@ time_init_1(int argc, VALUE *argv, VALUE time)
*
* +tz+ specifies the timezone.
* It can be an offset from UTC, given either as a string such as "+09:00"
+ * or a single letter "A".."Z" excluding "J" so-called military time zone,
* or as a number of seconds such as 32400.
* Or it can be a timezone object,
* see {Timezone argument}[#class-Time-label-Timezone+argument] for details.