1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Add --zone option to VCS

Which controls the timezone offset for `RUBY_RELEASE_DATE`.
This commit is contained in:
Nobuyoshi Nakada 2022-09-29 20:08:56 +09:00
parent 5a5644dadc
commit ab31d2e69f
No known key found for this signature in database
GPG key ID: 7CD2805BFA3770C6
Notes: git 2022-09-30 12:49:34 +09:00

View file

@ -95,11 +95,12 @@ class VCS
parser.separator(" VCS common options:")
parser.define("--[no-]dryrun") {|v| opts[:dryrun] = v}
parser.define("--[no-]debug") {|v| opts[:debug] = v}
parser.define("-z", "--zone=OFFSET", /\A[-+]\d\d:\d\d\z/) {|v| opts[:zone] = v}
opts
end
def release_date(time)
t = time.utc
t = time.getlocal(@zone)
[
t.strftime('#define RUBY_RELEASE_YEAR %Y'),
t.strftime('#define RUBY_RELEASE_MONTH %-m'),
@ -128,6 +129,7 @@ class VCS
def set_options(opts)
@debug = opts.fetch(:debug) {$DEBUG}
@dryrun = opts.fetch(:dryrun) {@debug}
@zone = opts.fetch(:zone) {'+09:00'}
end
attr_reader :dryrun, :debug