go_time 0.1.0 → 0.2.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f08a487416f03013ef2182fd438d3825edf66d86fffa1d49b46270e1b3e6d39e
4
- data.tar.gz: 1179d46591ac02e5a31a37d29108fbabc6122aaea93a27688db4cd4ad9322df1
3
+ metadata.gz: 4c88d500abb89a086a286c4b5047e410698d50a1917584953be6f16b6e91d91d
4
+ data.tar.gz: e1c296ab35fff78ac469519e71eab6f86c4911f2c30247ccf87e6082264d306e
5
5
  SHA512:
6
- metadata.gz: 99d075b096e5879e47212624d1e07139128d5755962d52bf9307cd1d441ed74c2be34d9fac5037cc9f4ed8977d9471cec67dad7225a5547b341b564251296e26
7
- data.tar.gz: bf70d0aaed27f291c3f492d5a54503b46b255aad18841cf9889196a459f5a39506e9a7fdfe2e6b53e090eed2d4b8d339d95daa36d6d1f6662ad5b37a004b578e
6
+ metadata.gz: a708b3775da86dfa900a1fc114acf1cfe95de36ad3fed214c9279232fbf74c990a3a2e27458184803bc7366757ef28cd2c05051911081ca4b17f26cf5b50f535
7
+ data.tar.gz: fbfc04046241439299223854ead51cf2c60ad4327576a3c66920078f8c3d7b9358fdbd85226aebcc530b25388a1d3e251bb400d1fcbc6072ec987574ee5efd22
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # GoTime - formats Time like Golang
2
2
 
3
- Do you remember the format of strftime? Wouldn't you like to use a concrete and understandable format like "01/02 03:04:05PM '06 -0700" like in the Golang?
3
+ Do you remember the format of strftime? Wouldn't you like to use a concrete and understandable format for example "01/02 03:04:05PM '06 -0700" like in the Golang?
4
4
 
5
5
  ## Installation
6
6
 
@@ -46,7 +46,18 @@ time.strftime("Mon Jan _2 15:04:05 2006")
46
46
  # => "Sun Mar 4 17:06:07 2012"
47
47
  ```
48
48
 
49
- For more information, please refer to the [Golang source code](https://golang.org/src/time/format.go).
49
+ For more information about format, please refer to the [Golang source code](https://golang.org/src/time/format.go).
50
+
51
+ ## Extensions
52
+
53
+ GoTime has extensions that support date and time representations in various languages.
54
+
55
+ ```ruby
56
+ require "go_time/ext/ja" # Japanese
57
+ time = Time.utc(2019, 5, 6, 7, 8, 9)
58
+ time.strftime("平成十八年(二〇〇六年)一月二日(火) 午後三時四分五秒")
59
+ # => "令和元年(二〇一九年)五月六日(月) 午前七時八分九秒"
60
+ ```
50
61
 
51
62
  ## Development
52
63
 
data/exe/gotime ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "go_time"
4
+
5
+ if ARGV.empty?
6
+ puts 'usage example: gotime "Mon, 02 Jan 2006 15:04:05 -0700"'
7
+ exit
8
+ end
9
+ puts GoTime.convert(ARGV.join(" "), exception: true)
@@ -1,81 +1,80 @@
1
- # frozen_string_literal: true
2
-
3
- module GoTime
4
- BASIC_CONVERT_TABLE = {
5
- "2006" => "%Y",
6
- "06" => "%y",
7
- "15" => "%H",
8
- "03" => "%I",
9
- "3" => "%-I",
10
- "January" => "%B",
11
- "Jan" => "%b",
12
- "01" => "%m",
13
- "1" => "%-m",
14
- "Monday" => "%A",
15
- "Mon" => "%a",
16
- "__2" => "%_j",
17
- "002" => "%j",
18
- "_2" => "%e",
19
- "02" => "%d",
20
- "2" => "%-d",
21
- "04" => "%M",
22
- "4" => "%-M",
23
- "05" => "%S",
24
- "5" => "%-S",
25
- "PM" => "%p",
26
- "pm" => "%P",
27
- "MST" => "%Z",
28
- "-07:00:00" => "%::z",
29
- "-07:00" => "%:z",
30
- "-0700" => "%z",
31
- ".000000000" => ".%9N",
32
- ".00000000" => ".%8N",
33
- ".0000000" => ".%7N",
34
- ".000000" => ".%6N",
35
- ".00000" => ".%5N",
36
- ".0000" => ".%4N",
37
- ".000" => ".%3N",
38
- ".00" => ".%2N",
39
- ".0" => ".%1N",
40
- ",000000000" => ",%9N",
41
- ",00000000" => ",%8N",
42
- ",0000000" => ",%7N",
43
- ",000000" => ",%6N",
44
- ",00000" => ",%5N",
45
- ",0000" => ",%4N",
46
- ",000" => ",%3N",
47
- ",00" => ",%2N",
48
- ",0" => ",%1N"
49
- }.freeze
50
- BASIC_CONVERT_REGEXP = Regexp.union(BASIC_CONVERT_TABLE.keys)
51
-
52
- @convert_table = {
53
- "Z07:00:00" => ->(t, _s) { t.utc? ? "Z" : t.strftime("%::z") },
54
- "Z07:00" => ->(t, _s) { t.utc? ? "Z" : t.strftime("%:z") },
55
- "Z070000" => ->(t, _s) { t.utc? ? "Z" : t.strftime("%::z").delete(":") },
56
- "Z0700" => ->(t, _s) { t.utc? ? "Z" : t.strftime("%z") },
57
- "Z07" => ->(t, _s) { t.utc? ? "Z" : t.strftime("%z").slice(0, 3) },
58
- "-070000" => ->(t, _s) { t.strftime("%::z").delete(":") }
59
- }.merge(BASIC_CONVERT_TABLE).merge({
60
- "-07" => ->(t, _s) { t.strftime("%z").slice(0, 3) }
61
- })
62
- @convert_table[".999999999"] = ->(t, s) { s[0] + t.strftime("%#{s.length - 1}N").sub(/0+$/, "") }
63
- @convert_table[".99999999"] = @convert_table[".999999999"]
64
- @convert_table[".9999999"] = @convert_table[".999999999"]
65
- @convert_table[".999999"] = @convert_table[".999999999"]
66
- @convert_table[".99999"] = @convert_table[".999999999"]
67
- @convert_table[".9999"] = @convert_table[".999999999"]
68
- @convert_table[".999"] = @convert_table[".999999999"]
69
- @convert_table[".99"] = @convert_table[".999999999"]
70
- @convert_table[".9"] = @convert_table[".999999999"]
71
- @convert_table[",999999999"] = @convert_table[".999999999"]
72
- @convert_table[",99999999"] = @convert_table[".999999999"]
73
- @convert_table[",9999999"] = @convert_table[".999999999"]
74
- @convert_table[",999999"] = @convert_table[".999999999"]
75
- @convert_table[",99999"] = @convert_table[".999999999"]
76
- @convert_table[",9999"] = @convert_table[".999999999"]
77
- @convert_table[",999"] = @convert_table[".999999999"]
78
- @convert_table[",99"] = @convert_table[".999999999"]
79
- @convert_table[",9"] = @convert_table[".999999999"]
80
- @convert_regexp = nil
81
- end
1
+ # frozen_string_literal: true
2
+
3
+ module GoTime
4
+ BASIC_CONVERT_TABLE = {
5
+ "2006" => "%Y",
6
+ "06" => "%y",
7
+ "15" => "%H",
8
+ "03" => "%I",
9
+ "3" => "%-I",
10
+ "January" => "%B",
11
+ "Jan" => "%b",
12
+ "01" => "%m",
13
+ "1" => "%-m",
14
+ "Monday" => "%A",
15
+ "Mon" => "%a",
16
+ "__2" => "%_j",
17
+ "002" => "%j",
18
+ "_2" => "%e",
19
+ "02" => "%d",
20
+ "2" => "%-d",
21
+ "04" => "%M",
22
+ "4" => "%-M",
23
+ "05" => "%S",
24
+ "5" => "%-S",
25
+ "PM" => "%p",
26
+ "pm" => "%P",
27
+ "MST" => "%Z",
28
+ "-07:00:00" => "%::z",
29
+ "-07:00" => "%:z",
30
+ "-0700" => "%z",
31
+ ".000000000" => ".%9N",
32
+ ".00000000" => ".%8N",
33
+ ".0000000" => ".%7N",
34
+ ".000000" => ".%6N",
35
+ ".00000" => ".%5N",
36
+ ".0000" => ".%4N",
37
+ ".000" => ".%3N",
38
+ ".00" => ".%2N",
39
+ ".0" => ".%1N",
40
+ ",000000000" => ",%9N",
41
+ ",00000000" => ",%8N",
42
+ ",0000000" => ",%7N",
43
+ ",000000" => ",%6N",
44
+ ",00000" => ",%5N",
45
+ ",0000" => ",%4N",
46
+ ",000" => ",%3N",
47
+ ",00" => ",%2N",
48
+ ",0" => ",%1N"
49
+ }.freeze
50
+ BASIC_CONVERT_REGEXP = Regexp.union(BASIC_CONVERT_TABLE.keys)
51
+
52
+ @convert_table = {
53
+ "Z07:00:00" => ->(t, _s) { t.utc? ? "Z" : t.strftime("%::z") },
54
+ "Z07:00" => ->(t, _s) { t.utc? ? "Z" : t.strftime("%:z") },
55
+ "Z070000" => ->(t, _s) { t.utc? ? "Z" : t.strftime("%::z").delete(":") },
56
+ "Z0700" => ->(t, _s) { t.utc? ? "Z" : t.strftime("%z") },
57
+ "Z07" => ->(t, _s) { t.utc? ? "Z" : t.strftime("%z").slice(0, 3) },
58
+ "-070000" => ->(t, _s) { t.strftime("%::z").delete(":") }
59
+ }.merge(BASIC_CONVERT_TABLE).merge({
60
+ "-07" => ->(t, _s) { t.strftime("%z").slice(0, 3) }
61
+ })
62
+ @convert_table[".999999999"] = ->(t, s) { s[0] + t.strftime("%#{s.length - 1}N").sub(/0+$/, "") }
63
+ @convert_table[".99999999"] = @convert_table[".999999999"]
64
+ @convert_table[".9999999"] = @convert_table[".999999999"]
65
+ @convert_table[".999999"] = @convert_table[".999999999"]
66
+ @convert_table[".99999"] = @convert_table[".999999999"]
67
+ @convert_table[".9999"] = @convert_table[".999999999"]
68
+ @convert_table[".999"] = @convert_table[".999999999"]
69
+ @convert_table[".99"] = @convert_table[".999999999"]
70
+ @convert_table[".9"] = @convert_table[".999999999"]
71
+ @convert_table[",999999999"] = @convert_table[".999999999"]
72
+ @convert_table[",99999999"] = @convert_table[".999999999"]
73
+ @convert_table[",9999999"] = @convert_table[".999999999"]
74
+ @convert_table[",999999"] = @convert_table[".999999999"]
75
+ @convert_table[",99999"] = @convert_table[".999999999"]
76
+ @convert_table[",9999"] = @convert_table[".999999999"]
77
+ @convert_table[",999"] = @convert_table[".999999999"]
78
+ @convert_table[",99"] = @convert_table[".999999999"]
79
+ @convert_table[",9"] = @convert_table[".999999999"]
80
+ end
@@ -0,0 +1,130 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "go_time"
4
+
5
+ module GoTime
6
+ module Ja
7
+ CHINESE_NUMERALS = %w[
8
+ 〇 一 二 三 四 五 六 七 八 九
9
+ 十 十一 十二 十三 十四 十五 十六 十七 十八 十九
10
+ 二十 二十一 二十二 二十三 二十四 二十五 二十六 二十七 二十八 二十九
11
+ 三十 三十一 三十二 三十三 三十四 三十五 三十六 三十七 三十八 三十九
12
+ 四十 四十一 四十二 四十三 四十四 四十五 四十六 四十七 四十八 四十九
13
+ 五十 五十一 五十二 五十三 五十四 五十五 五十六 五十七 五十八 五十九
14
+ 六十 六十一 六十二 六十三 六十四 六十五 六十六 六十七 六十八 六十九
15
+ 七十 七十一 七十二 七十三 七十四 七十五 七十六 七十七 七十八 七十九
16
+ 八十 八十一 八十二 八十三 八十四 八十五 八十六 八十七 八十八 八十九
17
+ 九十 九十一 九十二 九十三 九十四 九十五 九十六 九十七 九十八 九十九
18
+ ].freeze
19
+
20
+ FULLWIDTH_NUMBERS = %w[
21
+ 0 1 2 3 4 5 6 7 8 9
22
+ 10 11 12 13 14 15 16 17 18 19
23
+ 20 21 22 23 24 25 26 27 28 29
24
+ 30 31 32 33 34 35 36 37 38 39
25
+ 40 41 42 43 44 45 46 47 48 49
26
+ 50 51 52 53 54 55 56 57 58 59
27
+ 60 61 62 63 64 65 66 67 68 69
28
+ 70 71 72 73 74 75 76 77 78 79
29
+ 80 81 82 83 84 85 86 87 88 89
30
+ 90 91 92 93 94 95 96 97 98 99
31
+ ].freeze
32
+
33
+ ERA_REPRESENTATIONS = {
34
+ "令和" => { "平成" => "令和", "㍻" => "㋿", "H" => "R", "H" => "R" }.freeze,
35
+ "平成" => { "平成" => "平成", "㍻" => "㍻", "H" => "H", "H" => "H" }.freeze,
36
+ "昭和" => { "平成" => "昭和", "㍻" => "㍼", "H" => "S", "H" => "S" }.freeze,
37
+ "大正" => { "平成" => "大正", "㍻" => "㍽", "H" => "T", "H" => "T" }.freeze,
38
+ "明治" => { "平成" => "明治", "㍻" => "㍾", "H" => "M", "H" => "M" }.freeze
39
+ }.freeze
40
+
41
+ def self.japanese_year(time)
42
+ if time >= Time.new(2019, 4, 30)
43
+ ["令和", time.year - 2018]
44
+ elsif time >= Time.new(1989, 1, 8)
45
+ ["平成", time.year - 1988]
46
+ elsif time >= Time.new(1926, 12, 25)
47
+ ["昭和", time.year - 1925]
48
+ elsif time >= Time.new(1912, 7, 30)
49
+ ["大正", time.year - 1911]
50
+ elsif time >= Time.new(1868, 1, 25)
51
+ ["明治", time.year - 1867]
52
+ else
53
+ raise RangeError
54
+ end
55
+ end
56
+ end
57
+
58
+ @convert_table["二〇〇六"] = lambda { |t, _s|
59
+ t.year.to_s.tr("0123456789", "〇一二三四五六七八九")
60
+ }
61
+ @convert_table["2006"] = lambda { |t, _s|
62
+ t.year.to_s.tr("0123456789", "0123456789")
63
+ }
64
+ @convert_table["06"] = lambda { |t, _s|
65
+ t.year.to_s[-2, 2].tr("0123456789", "0123456789")
66
+ }
67
+ @convert_table["平成"] = @convert_table["㍻"] = lambda { |t, s|
68
+ era, _year = Ja.japanese_year(t)
69
+ Ja::ERA_REPRESENTATIONS[era][s]
70
+ }
71
+ @convert_table["H18"] = @convert_table["H18"] = lambda { |t, s|
72
+ era, year = Ja.japanese_year(t)
73
+ "#{Ja::ERA_REPRESENTATIONS[era][s[0]]}#{Ja::FULLWIDTH_NUMBERS[year]}"
74
+ }
75
+ @convert_table["H18"] = lambda { |t, _s|
76
+ era, year = Ja.japanese_year(t)
77
+ "#{Ja::ERA_REPRESENTATIONS[era]['H']}#{sprintf('%02d', year)}"
78
+ }
79
+ @convert_table["十八年"] = lambda { |t, _s|
80
+ _era, year = Ja.japanese_year(t)
81
+ "#{year == 1 ? '元' : Ja::CHINESE_NUMERALS.at(year)}年"
82
+ }
83
+ @convert_table["18年"] = lambda { |t, _s|
84
+ _era, year = Ja.japanese_year(t)
85
+ "#{year == 1 ? '元' : Ja::FULLWIDTH_NUMBERS.at(year)}年"
86
+ }
87
+ @convert_table["18年"] = lambda { |t, _s|
88
+ _era, year = Ja.japanese_year(t)
89
+ "#{year == 1 ? '元' : sprintf('%02d', year)}年"
90
+ }
91
+ @convert_table["十八"] = lambda { |t, _s|
92
+ _era, year = Ja.japanese_year(t)
93
+ Ja::CHINESE_NUMERALS.at(year)
94
+ }
95
+ @convert_table["18"] = lambda { |t, _s|
96
+ _era, year = Ja.japanese_year(t)
97
+ Ja::FULLWIDTH_NUMBERS.at(year)
98
+ }
99
+ @convert_table["18"] = lambda { |t, _s|
100
+ _era, year = Ja.japanese_year(t)
101
+ sprintf("%02d", year)
102
+ }
103
+ @convert_table["十五"] = ->(t, _s) { Ja::CHINESE_NUMERALS.at(t.hour) }
104
+ @convert_table["15"] = ->(t, _s) { "0#{Ja::FULLWIDTH_NUMBERS.at(t.hour)}"[-2, 2] }
105
+ @convert_table["一"] = ->(t, _s) { Ja::CHINESE_NUMERALS.at(t.month) }
106
+ @convert_table["01"] = ->(t, _s) { "0#{Ja::FULLWIDTH_NUMBERS.at(t.month)}"[-2, 2] }
107
+ @convert_table["1"] = ->(t, _s) { Ja::FULLWIDTH_NUMBERS.at(t.month) }
108
+ @convert_table["睦月"] = lambda { |t, _s|
109
+ %w[睦月 如月 弥生 卯月 皐月 水無月 文月 葉月 長月 神無月 霜月 師走].at(t.month - 1)
110
+ }
111
+ @convert_table["二"] = ->(t, _s) { Ja::CHINESE_NUMERALS.at(t.mday) }
112
+ @convert_table["02"] = ->(t, _s) { "0#{Ja::FULLWIDTH_NUMBERS.at(t.mday)}"[-2, 2] }
113
+ @convert_table["_2"] = ->(t, _s) { " #{Ja::FULLWIDTH_NUMBERS.at(t.mday)}"[-2, 2] }
114
+ @convert_table["2"] = ->(t, _s) { Ja::FULLWIDTH_NUMBERS.at(t.mday) }
115
+ @convert_table["火"] = ->(t, _s) { %w[日 月 火 水 木 金 土].at(t.wday) }
116
+ @convert_table["午後"] = ->(t, _s) { t.hour < 12 ? "午前" : "午後" }
117
+ @convert_table["PM"] = ->(t, _s) { t.hour < 12 ? "AM" : "PM" }
118
+ @convert_table["pm"] = ->(t, _s) { t.hour < 12 ? "am" : "pm" }
119
+ @convert_table["三"] = ->(t, _s) { Ja::CHINESE_NUMERALS.at(t.hour % 12) }
120
+ @convert_table["03"] = ->(t, _s) { "0#{Ja::FULLWIDTH_NUMBERS.at(t.hour % 12)}"[-2, 2] }
121
+ @convert_table["3"] = ->(t, _s) { Ja::FULLWIDTH_NUMBERS.at(t.hour % 12) }
122
+ @convert_table["四"] = ->(t, _s) { Ja::CHINESE_NUMERALS.at(t.min) }
123
+ @convert_table["04"] = ->(t, _s) { "0#{Ja::FULLWIDTH_NUMBERS.at(t.min)}"[-2, 2] }
124
+ @convert_table["4"] = ->(t, _s) { Ja::FULLWIDTH_NUMBERS.at(t.min) }
125
+ @convert_table["五"] = ->(t, _s) { Ja::CHINESE_NUMERALS.at(t.sec) }
126
+ @convert_table["05"] = ->(t, _s) { "0#{Ja::FULLWIDTH_NUMBERS.at(t.sec)}"[-2, 2] }
127
+ @convert_table["5"] = ->(t, _s) { Ja::FULLWIDTH_NUMBERS.at(t.sec) }
128
+
129
+ update_convert_regexp
130
+ end
@@ -1,9 +1,7 @@
1
- # frozen_string_literal: true
2
-
3
- module GoTime
4
- refine Time do
5
- def format(fmt)
6
- GoTime.format(self, fmt)
7
- end
8
- end
9
- end
1
+ module GoTime
2
+ refine Time do
3
+ def format(fmt)
4
+ GoTime.format(self, fmt)
5
+ end
6
+ end
7
+ end
@@ -1,11 +1,11 @@
1
- # frozen_string_literal: true
2
-
3
- require "go_time"
4
-
5
- class Time
6
- alias_method :_orig_strftime, :strftime
7
-
8
- def strftime(fmt)
9
- GoTime.strftime(self, fmt)
10
- end
11
- end
1
+ # frozen_string_literal: true
2
+
3
+ require "go_time"
4
+
5
+ class Time
6
+ alias _orig_strftime strftime
7
+
8
+ def strftime(fmt)
9
+ GoTime.strftime(self, fmt)
10
+ end
11
+ end
@@ -1,5 +1,3 @@
1
- # frozen_string_literal: true
2
-
3
1
  module GoTime
4
- VERSION = "0.1.0"
2
+ VERSION = -"0.2.0"
5
3
  end
data/lib/go_time.rb CHANGED
@@ -9,12 +9,10 @@ require_relative "go_time/version"
9
9
  module GoTime
10
10
  # Formats time according to Go-like format string
11
11
  #
12
- # @param [Time] time
13
- # @param [String] fmt Go-like format string
12
+ # @param time [Time]
13
+ # @param fmt [String] Go-like format string
14
14
  # @return [String] formatted string
15
15
  def self.format(time, fmt)
16
- update_convert_regexp unless @convert_regexp
17
-
18
16
  fmt.gsub(@convert_regexp) do |matched|
19
17
  conv = @convert_table[matched]
20
18
  case conv
@@ -28,12 +26,10 @@ module GoTime
28
26
 
29
27
  # Formats time according to Go-like format or strftime format string
30
28
  #
31
- # @param [Time] time
32
- # @param [String] fmt Go-like format or strftime format string
29
+ # @param time [Time]
30
+ # @param fmt [String] Go-like format or strftime format string
33
31
  # @return [String] formatted string
34
32
  def self.strftime(time, fmt)
35
- update_convert_regexp unless @convert_regexp
36
-
37
33
  converted_fmt = fmt.gsub(@convert_regexp) do |matched|
38
34
  conv = @convert_table[matched]
39
35
  case conv
@@ -49,13 +45,22 @@ module GoTime
49
45
 
50
46
  # Converts Go-like format string to strftime format string
51
47
  #
52
- # @param [String] fmt Go-like format string
48
+ # @param fmt [String] Go-like format string
49
+ # @param exception [Boolean] If true, raise ArgumentError when there is a syntax that does not support Time#strftime.
53
50
  # @return [String] strftime format string
54
- def self.convert(fmt)
55
- fmt.gsub(BASIC_CONVERT_REGEXP, BASIC_CONVERT_TABLE)
51
+ def self.convert(fmt, exception: false)
52
+ ret = fmt.gsub(BASIC_CONVERT_REGEXP, BASIC_CONVERT_TABLE)
53
+ if exception
54
+ matched = ret.match(@convert_regexp)
55
+ raise ArgumentError, %(unsupported syntax "#{matched}") if matched
56
+ end
57
+ ret
56
58
  end
57
59
 
58
60
  def self.update_convert_regexp
59
61
  @convert_regexp = Regexp.union(@convert_table.keys)
60
62
  end
63
+
64
+ private_class_method :update_convert_regexp
65
+ update_convert_regexp
61
66
  end
data/sig/go_time.rbs ADDED
@@ -0,0 +1,23 @@
1
+ # formats Time like Golang
2
+ module GoTime
3
+ # Formats time according to Go-like format string
4
+ #
5
+ # @param time [Time]
6
+ # @param fmt [String] Go-like format string
7
+ # @return [String] formatted string
8
+ def self.format: (Time time, String fmt) -> String
9
+
10
+ # Formats time according to Go-like format or strftime format string
11
+ #
12
+ # @param time [Time]
13
+ # @param fmt [String] Go-like format or strftime format string
14
+ # @return [String] formatted string
15
+ def self.strftime: (Time time, String fmt) -> String
16
+
17
+ # Converts Go-like format string to strftime format string
18
+ #
19
+ # @param fmt [String] Go-like format string
20
+ # @param exception [Boolean] If true, raise ArgumentError when there is a syntax that does not support Time#strftime.
21
+ # @return [String] strftime format string
22
+ def self.convert: (String fmt, ?exception: bool) -> String
23
+ end
metadata CHANGED
@@ -1,19 +1,20 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: go_time
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - nodai2hITC
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-09-26 00:00:00.000000000 Z
11
+ date: 2022-01-29 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: Formats Time according to Go-like format like "01/02 03:04:05PM '06 -0700"
14
14
  email:
15
15
  - nodai2h.itc@gmail.com
16
- executables: []
16
+ executables:
17
+ - gotime
17
18
  extensions: []
18
19
  extra_rdoc_files: []
19
20
  files:
@@ -24,13 +25,16 @@ files:
24
25
  - Rakefile
25
26
  - bin/console
26
27
  - bin/setup
28
+ - exe/gotime
27
29
  - go_time.gemspec
28
30
  - lib/go_time.rb
29
31
  - lib/go_time/constants.rb
30
32
  - lib/go_time/convert_table.rb
33
+ - lib/go_time/ext/ja.rb
31
34
  - lib/go_time/refine.rb
32
35
  - lib/go_time/strftime.rb
33
36
  - lib/go_time/version.rb
37
+ - sig/go_time.rbs
34
38
  homepage: https://github.com/nodai2hITC/go_time
35
39
  licenses:
36
40
  - MIT
@@ -52,7 +56,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
52
56
  - !ruby/object:Gem::Version
53
57
  version: '0'
54
58
  requirements: []
55
- rubygems_version: 3.2.27
59
+ rubygems_version: 3.3.5
56
60
  signing_key:
57
61
  specification_version: 4
58
62
  summary: formats Time like Golang