decentworks-date-support 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.
Files changed (161) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +89 -3
  3. data/LICENSE +1 -1
  4. data/README.md +268 -24
  5. data/lib/decentworks/date_support/configuration.rb +73 -0
  6. data/lib/decentworks/date_support/date.rb +9 -0
  7. data/lib/decentworks/date_support/date_extension.rb +761 -0
  8. data/lib/decentworks/date_support/date_time.rb +9 -0
  9. data/lib/decentworks/date_support/time.rb +7 -0
  10. data/lib/decentworks/date_support/time_extension.rb +742 -0
  11. data/lib/decentworks/date_support/time_with_zone.rb +12 -0
  12. data/lib/decentworks/date_support/version.rb +7 -0
  13. data/lib/decentworks/date_support.rb +8 -321
  14. data/lib/decentworks-date-support.rb +3 -0
  15. data/lib/generators/decentworks/date_support/install/install_generator.rb +26 -0
  16. data/lib/generators/decentworks/date_support/install/templates/decentworks_date_support.rb.tt +50 -0
  17. data/sig/decentworks/date_support/configuration.rbs +25 -0
  18. data/sig/decentworks/date_support/date.rbs +4 -0
  19. data/sig/decentworks/date_support/date_extension.rbs +244 -0
  20. data/sig/decentworks/date_support/date_time.rbs +4 -0
  21. data/sig/decentworks/date_support/time.rbs +4 -0
  22. data/sig/decentworks/date_support/time_extension.rbs +248 -0
  23. data/sig/decentworks/date_support/time_with_zone.rbs +21 -0
  24. data/sig/decentworks/date_support/version.rbs +5 -0
  25. metadata +27 -143
  26. data/.gem_rbs_collection/actionpack/7.2/.rbs_meta.yaml +0 -9
  27. data/.gem_rbs_collection/actionpack/7.2/actioncontroller-7.2.rbs +0 -14
  28. data/.gem_rbs_collection/actionpack/7.2/actioncontroller.rbs +0 -290
  29. data/.gem_rbs_collection/actionpack/7.2/actiondispatch.rbs +0 -349
  30. data/.gem_rbs_collection/actionpack/7.2/actionpack-generated.rbs +0 -11497
  31. data/.gem_rbs_collection/actionpack/7.2/patch.rbs +0 -77
  32. data/.gem_rbs_collection/actionview/6.0/.rbs_meta.yaml +0 -9
  33. data/.gem_rbs_collection/actionview/6.0/actionview-generated.rbs +0 -8976
  34. data/.gem_rbs_collection/actionview/6.0/actionview.rbs +0 -1940
  35. data/.gem_rbs_collection/actionview/6.0/patch.rbs +0 -57
  36. data/.gem_rbs_collection/activesupport/7.0/.rbs_meta.yaml +0 -9
  37. data/.gem_rbs_collection/activesupport/7.0/activesupport-7.0.rbs +0 -381
  38. data/.gem_rbs_collection/activesupport/7.0/activesupport-generated.rbs +0 -11633
  39. data/.gem_rbs_collection/activesupport/7.0/activesupport.rbs +0 -724
  40. data/.gem_rbs_collection/activesupport/7.0/manifest.yaml +0 -15
  41. data/.gem_rbs_collection/activesupport/7.0/patch.rbs +0 -55
  42. data/.gem_rbs_collection/ast/2.4/.rbs_meta.yaml +0 -9
  43. data/.gem_rbs_collection/ast/2.4/ast.rbs +0 -73
  44. data/.gem_rbs_collection/cgi/0.5/.rbs_meta.yaml +0 -9
  45. data/.gem_rbs_collection/cgi/0.5/core.rbs +0 -925
  46. data/.gem_rbs_collection/cgi/0.5/manifest.yaml +0 -3
  47. data/.gem_rbs_collection/concurrent-ruby/1.1/.rbs_meta.yaml +0 -9
  48. data/.gem_rbs_collection/concurrent-ruby/1.1/array.rbs +0 -4
  49. data/.gem_rbs_collection/concurrent-ruby/1.1/atomic_reference.rbs +0 -16
  50. data/.gem_rbs_collection/concurrent-ruby/1.1/executor.rbs +0 -96
  51. data/.gem_rbs_collection/concurrent-ruby/1.1/hash.rbs +0 -4
  52. data/.gem_rbs_collection/concurrent-ruby/1.1/map.rbs +0 -68
  53. data/.gem_rbs_collection/concurrent-ruby/1.1/promises.rbs +0 -249
  54. data/.gem_rbs_collection/concurrent-ruby/1.1/set.rbs +0 -4
  55. data/.gem_rbs_collection/concurrent-ruby/1.1/timer_task.rbs +0 -47
  56. data/.gem_rbs_collection/concurrent-ruby/1.1/utility/processor_counter.rbs +0 -5
  57. data/.gem_rbs_collection/connection_pool/2.4/.rbs_meta.yaml +0 -9
  58. data/.gem_rbs_collection/connection_pool/2.4/connection_pool.rbs +0 -34
  59. data/.gem_rbs_collection/connection_pool/2.4/manifest.yaml +0 -2
  60. data/.gem_rbs_collection/diff-lcs/1.5/.rbs_meta.yaml +0 -9
  61. data/.gem_rbs_collection/diff-lcs/1.5/diff-lcs.rbs +0 -11
  62. data/.gem_rbs_collection/faker/3.4.2/.rbs_meta.yaml +0 -9
  63. data/.gem_rbs_collection/faker/3.4.2/faker-2.23.rbs +0 -90
  64. data/.gem_rbs_collection/faker/3.4.2/faker.rbs +0 -18
  65. data/.gem_rbs_collection/i18n/1.10/.rbs_meta.yaml +0 -9
  66. data/.gem_rbs_collection/i18n/1.10/backend.rbs +0 -274
  67. data/.gem_rbs_collection/i18n/1.10/i18n.rbs +0 -116
  68. data/.gem_rbs_collection/lint_roller/1.1/.rbs_meta.yaml +0 -9
  69. data/.gem_rbs_collection/lint_roller/1.1/lint_roller.rbs +0 -48
  70. data/.gem_rbs_collection/minitest/5.25/.rbs_meta.yaml +0 -9
  71. data/.gem_rbs_collection/minitest/5.25/minitest/abstract_reporter.rbs +0 -52
  72. data/.gem_rbs_collection/minitest/5.25/minitest/assertion.rbs +0 -17
  73. data/.gem_rbs_collection/minitest/5.25/minitest/assertions.rbs +0 -590
  74. data/.gem_rbs_collection/minitest/5.25/minitest/backtrace_filter.rbs +0 -23
  75. data/.gem_rbs_collection/minitest/5.25/minitest/bench_spec.rbs +0 -102
  76. data/.gem_rbs_collection/minitest/5.25/minitest/benchmark.rbs +0 -259
  77. data/.gem_rbs_collection/minitest/5.25/minitest/composite_reporter.rbs +0 -25
  78. data/.gem_rbs_collection/minitest/5.25/minitest/compress.rbs +0 -13
  79. data/.gem_rbs_collection/minitest/5.25/minitest/error_on_warning.rbs +0 -3
  80. data/.gem_rbs_collection/minitest/5.25/minitest/expectation.rbs +0 -2
  81. data/.gem_rbs_collection/minitest/5.25/minitest/expectations.rbs +0 -21
  82. data/.gem_rbs_collection/minitest/5.25/minitest/guard.rbs +0 -64
  83. data/.gem_rbs_collection/minitest/5.25/minitest/mock.rbs +0 -64
  84. data/.gem_rbs_collection/minitest/5.25/minitest/parallel/executor.rbs +0 -46
  85. data/.gem_rbs_collection/minitest/5.25/minitest/parallel/test/class_methods.rbs +0 -5
  86. data/.gem_rbs_collection/minitest/5.25/minitest/parallel/test.rbs +0 -3
  87. data/.gem_rbs_collection/minitest/5.25/minitest/parallel.rbs +0 -2
  88. data/.gem_rbs_collection/minitest/5.25/minitest/pride_io.rbs +0 -62
  89. data/.gem_rbs_collection/minitest/5.25/minitest/pride_lol.rbs +0 -19
  90. data/.gem_rbs_collection/minitest/5.25/minitest/progress_reporter.rbs +0 -11
  91. data/.gem_rbs_collection/minitest/5.25/minitest/reportable.rbs +0 -53
  92. data/.gem_rbs_collection/minitest/5.25/minitest/reporter.rbs +0 -5
  93. data/.gem_rbs_collection/minitest/5.25/minitest/result.rbs +0 -28
  94. data/.gem_rbs_collection/minitest/5.25/minitest/runnable.rbs +0 -163
  95. data/.gem_rbs_collection/minitest/5.25/minitest/skip.rbs +0 -6
  96. data/.gem_rbs_collection/minitest/5.25/minitest/spec/dsl/instance_methods.rbs +0 -48
  97. data/.gem_rbs_collection/minitest/5.25/minitest/spec/dsl.rbs +0 -129
  98. data/.gem_rbs_collection/minitest/5.25/minitest/spec.rbs +0 -11
  99. data/.gem_rbs_collection/minitest/5.25/minitest/statistics_reporter.rbs +0 -81
  100. data/.gem_rbs_collection/minitest/5.25/minitest/summary_reporter.rbs +0 -18
  101. data/.gem_rbs_collection/minitest/5.25/minitest/test/lifecycle_hooks.rbs +0 -92
  102. data/.gem_rbs_collection/minitest/5.25/minitest/test.rbs +0 -69
  103. data/.gem_rbs_collection/minitest/5.25/minitest/unexpected_error.rbs +0 -12
  104. data/.gem_rbs_collection/minitest/5.25/minitest/unexpected_warning.rbs +0 -6
  105. data/.gem_rbs_collection/minitest/5.25/minitest/unit/test_case.rbs +0 -3
  106. data/.gem_rbs_collection/minitest/5.25/minitest/unit.rbs +0 -4
  107. data/.gem_rbs_collection/minitest/5.25/minitest.rbs +0 -115
  108. data/.gem_rbs_collection/nokogiri/1.11/.rbs_meta.yaml +0 -9
  109. data/.gem_rbs_collection/nokogiri/1.11/nokogiri.rbs +0 -2332
  110. data/.gem_rbs_collection/nokogiri/1.11/patch.rbs +0 -4
  111. data/.gem_rbs_collection/parallel/1.20/.rbs_meta.yaml +0 -9
  112. data/.gem_rbs_collection/parallel/1.20/parallel.rbs +0 -86
  113. data/.gem_rbs_collection/parser/3.2/.rbs_meta.yaml +0 -9
  114. data/.gem_rbs_collection/parser/3.2/manifest.yaml +0 -7
  115. data/.gem_rbs_collection/parser/3.2/parser.rbs +0 -194
  116. data/.gem_rbs_collection/parser/3.2/polyfill.rbs +0 -4
  117. data/.gem_rbs_collection/rack/2.2/.rbs_meta.yaml +0 -9
  118. data/.gem_rbs_collection/rack/2.2/manifest.yaml +0 -3
  119. data/.gem_rbs_collection/rack/2.2/rack.rbs +0 -1480
  120. data/.gem_rbs_collection/rails-dom-testing/2.0/.rbs_meta.yaml +0 -9
  121. data/.gem_rbs_collection/rails-dom-testing/2.0/rails-dom-testing.rbs +0 -51
  122. data/.gem_rbs_collection/rails-html-sanitizer/1.6/.rbs_meta.yaml +0 -9
  123. data/.gem_rbs_collection/rails-html-sanitizer/1.6/rails-html-sanitizer.rbs +0 -53
  124. data/.gem_rbs_collection/railties/6.0/.rbs_meta.yaml +0 -9
  125. data/.gem_rbs_collection/railties/6.0/manifest.yaml +0 -2
  126. data/.gem_rbs_collection/railties/6.0/patch.rbs +0 -17
  127. data/.gem_rbs_collection/railties/6.0/railties-generated.rbs +0 -4822
  128. data/.gem_rbs_collection/railties/6.0/railties.rbs +0 -44
  129. data/.gem_rbs_collection/rainbow/3.0/.rbs_meta.yaml +0 -9
  130. data/.gem_rbs_collection/rainbow/3.0/global.rbs +0 -7
  131. data/.gem_rbs_collection/rainbow/3.0/presenter.rbs +0 -209
  132. data/.gem_rbs_collection/rainbow/3.0/rainbow.rbs +0 -5
  133. data/.gem_rbs_collection/rake/13.0/.rbs_meta.yaml +0 -9
  134. data/.gem_rbs_collection/rake/13.0/manifest.yaml +0 -2
  135. data/.gem_rbs_collection/rake/13.0/rake.rbs +0 -39
  136. data/.gem_rbs_collection/regexp_parser/2.8/.rbs_meta.yaml +0 -9
  137. data/.gem_rbs_collection/regexp_parser/2.8/regexp_parser.rbs +0 -17
  138. data/.gem_rbs_collection/rubocop/1.57/.rbs_meta.yaml +0 -9
  139. data/.gem_rbs_collection/rubocop/1.57/rubocop.rbs +0 -208
  140. data/.gem_rbs_collection/rubocop-ast/1.46/.rbs_meta.yaml +0 -9
  141. data/.gem_rbs_collection/rubocop-ast/1.46/rubocop-ast.rbs +0 -903
  142. data/.gem_rbs_collection/thor/1.2/.rbs_meta.yaml +0 -9
  143. data/.gem_rbs_collection/thor/1.2/thor.rbs +0 -62
  144. data/.gem_rbs_collection/tzinfo/2.0/.rbs_meta.yaml +0 -9
  145. data/.gem_rbs_collection/tzinfo/2.0/manifest.yaml +0 -7
  146. data/.gem_rbs_collection/tzinfo/2.0/tzinfo.rbs +0 -600
  147. data/.rspec +0 -3
  148. data/.rubocop.yml +0 -8
  149. data/.ruby-version +0 -1
  150. data/CODE_OF_CONDUCT.md +0 -132
  151. data/LICENSE.txt +0 -21
  152. data/Rakefile +0 -12
  153. data/Steepfile +0 -43
  154. data/lib/decentworks/active_support/time_with_zone_support.rb +0 -327
  155. data/lib/decentworks/date/support/version.rb +0 -9
  156. data/lib/decentworks_date_support.rb +0 -4
  157. data/rbs_collection.lock.yaml +0 -288
  158. data/rbs_collection.yaml +0 -41
  159. data/sig/decentworks/active_support/time_with_zone_support.rbs +0 -109
  160. data/sig/decentworks/date/support.rbs +0 -8
  161. data/sig/decentworks/date_support.rbs +0 -107
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "active_support"
4
+ require "active_support/time" # ::ActiveSupport::TimeWithZone の定義元
5
+
6
+ require_relative "time_extension"
7
+
8
+ module ActiveSupport
9
+ class TimeWithZone
10
+ include ::Decentworks::DateSupport::TimeExtension
11
+ end
12
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Decentworks
4
+ module DateSupport
5
+ VERSION = "0.2.0"
6
+ end
7
+ end
@@ -1,323 +1,10 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "date"
4
-
5
- module Decentworks
6
- module DateSupport
7
- refine ::Date do
8
- # ###############################################################################################################
9
- # 週関係
10
- # ###############################################################################################################
11
-
12
- #
13
- # 今週
14
- #
15
-
16
- # 現在の日付が属する週の始まりの日付
17
- #
18
- # @param beginning_of_week 週の始まりの曜日。省略した場合は、config.beginning_of_weekの設定に従います。
19
- def beginning_of_this_week(beginning_of_week = nil)
20
- beginning_of_week(beginning_of_week.presence || ::Date.beginning_of_week) # steep:ignore NoMethod
21
- end
22
-
23
- # 現在の日付が属する週の終わりの日付
24
- #
25
- # @param beginning_of_week 週の始まりの曜日。省略した場合は、config.beginning_of_weekの設定に従います。
26
- def end_of_this_week(beginning_of_week = nil)
27
- next_week # steep:ignore NoMethod
28
- .beginning_of_this_week(beginning_of_week)
29
- .yesterday
30
- end
31
-
32
- # 今週の期間
33
- #
34
- # @param beginning_of_week 週の始まりの曜日。省略した場合は、config.beginning_of_weekの設定に従います。
35
- def all_this_week(beginning_of_week = nil)
36
- ::Range.new(
37
- beginning_of_this_week(beginning_of_week),
38
- end_of_this_week(beginning_of_week)
39
- )
40
- end
41
-
42
- # ###############################################################################################################
43
- # 月関係
44
- # ###############################################################################################################
45
-
46
- #
47
- # 今月関係
48
- #
49
-
50
- # 現在の日付が属する月の期間
51
- def all_this_month
52
- ::Range.new(
53
- beginning_of_month.to_date, # steep:ignore NoMethod
54
- end_of_month.to_date # steep:ignore NoMethod
55
- )
56
- end
57
-
58
- #
59
- # Nヶ月前関係
60
- #
61
-
62
- # 2ヶ月前の日付
63
- def two_months_ago = months_ago(2) # steep:ignore NoMethod
64
-
65
- # 3ヶ月前の日付
66
- def three_months_ago = months_ago(3) # steep:ignore NoMethod
67
-
68
- # 4ヶ月前の日付
69
- def four_months_ago = months_ago(4) # steep:ignore NoMethod
70
-
71
- # 5ヶ月前の日付
72
- def five_months_ago = months_ago(5) # steep:ignore NoMethod
73
-
74
- # 6ヶ月前の日付
75
- def six_months_ago = months_ago(6) # steep:ignore NoMethod
76
-
77
- # 半年前の日
78
- alias_method :half_year_ago, :six_months_ago
79
-
80
- # 7ヶ月前の日付
81
- def seven_months_ago = months_ago(7) # steep:ignore NoMethod
82
-
83
- # 8ヶ月前の日付
84
- def eight_months_ago = months_ago(8) # steep:ignore NoMethod
85
-
86
- # 9ヶ月前の日付
87
- def nine_months_ago = months_ago(9) # steep:ignore NoMethod
88
-
89
- # 10ヶ月前の日付
90
- def ten_months_ago = months_ago(10) # steep:ignore NoMethod
91
-
92
- # 11ヶ月前の日付
93
- def eleven_months_ago = months_ago(11) # steep:ignore NoMethod
94
-
95
- #
96
- # Nヶ月後関係
97
- #
98
-
99
- # 2ヶ月後の日付
100
- def two_months_since = months_since(2) # steep:ignore NoMethod
101
-
102
- # 3ヶ月後の日付
103
- def three_months_since = months_since(3) # steep:ignore NoMethod
104
-
105
- # 4ヶ月後の日付
106
- def four_months_since = months_since(4) # steep:ignore NoMethod
107
-
108
- # 5ヶ月後の日付
109
- def five_months_since = months_since(5) # steep:ignore NoMethod
110
-
111
- # 6ヶ月後の日付
112
- def six_months_since = months_since(6) # steep:ignore NoMethod
113
-
114
- # 半年前の日
115
- alias_method :half_year_since, :six_months_since
116
-
117
- # 7ヶ月後の日付
118
- def seven_months_since = months_since(7) # steep:ignore NoMethod
119
-
120
- # 8ヶ月後の日付
121
- def eight_months_since = months_since(8) # steep:ignore NoMethod
122
-
123
- # 9ヶ月後の日付
124
- def nine_months_since = months_since(9) # steep:ignore NoMethod
125
-
126
- # 10ヶ月後の日付
127
- def ten_months_since = months_since(10) # steep:ignore NoMethod
128
-
129
- # 11ヶ月後の日付
130
- def eleven_months_since = months_since(11) # steep:ignore NoMethod
131
-
132
- #
133
- # 暦月関係
134
- #
135
-
136
- # 1月の月初
137
- def beginning_of_january = change(month: 1, day: 1) # steep:ignore NoMethod
138
-
139
- # 1月の月末
140
- def end_of_january = beginning_of_january.end_of_month
141
-
142
- # 1月の期間
143
- def all_january = ::Range.new(beginning_of_january, end_of_january)
144
-
145
- # 2月の月初
146
- def beginning_of_february = change(month: 2, day: 1) # steep:ignore NoMethod
147
-
148
- # 2月の月末
149
- def end_of_february = beginning_of_february.end_of_month
150
-
151
- # 2月の期間
152
- def all_february = ::Range.new(beginning_of_february, end_of_february)
153
-
154
- # 3月の月初
155
- def beginning_of_march = change(month: 3, day: 1) # steep:ignore NoMethod
156
-
157
- # 3月の月末
158
- def end_of_march = beginning_of_march.end_of_month
159
-
160
- # 3月の期間
161
- def all_march = ::Range.new(beginning_of_march, end_of_march)
162
-
163
- # 4月の月初
164
- def beginning_of_april = change(month: 4, day: 1) # steep:ignore NoMethod
165
-
166
- # 4月の月末
167
- def end_of_april = beginning_of_april.end_of_month
168
-
169
- # 4月の期間
170
- def all_april = ::Range.new(beginning_of_april, end_of_april)
171
-
172
- # 5月の月初
173
- def beginning_of_may = change(month: 5, day: 1) # steep:ignore NoMethod
174
-
175
- # 5月の月末
176
- def end_of_may = beginning_of_may.end_of_month
177
-
178
- # 5月の期間
179
- def all_may = ::Range.new(beginning_of_may, end_of_may)
180
-
181
- # 6月の月初
182
- def beginning_of_june = change(month: 6, day: 1) # steep:ignore NoMethod
183
-
184
- # 6月の月末
185
- def end_of_june = beginning_of_june.end_of_month
186
-
187
- # 6月の期間
188
- def all_june = ::Range.new(beginning_of_june, end_of_june)
189
-
190
- # 7月の月初
191
- def beginning_of_july = change(month: 7, day: 1) # steep:ignore NoMethod
192
-
193
- # 7月の月末
194
- def end_of_july = beginning_of_july.end_of_month
195
-
196
- # 7月の期間
197
- def all_july = ::Range.new(beginning_of_july, end_of_july)
198
-
199
- # 8月の月初
200
- def beginning_of_august = change(month: 8, day: 1) # steep:ignore NoMethod
201
-
202
- # 8月の月末
203
- def end_of_august = beginning_of_august.end_of_month
204
-
205
- # 8月の期間
206
- def all_august = ::Range.new(beginning_of_august, end_of_august)
207
-
208
- # 9月の月初
209
- def beginning_of_september = change(month: 9, day: 1) # steep:ignore NoMethod
210
-
211
- # 9月の月末
212
- def end_of_september = beginning_of_september.end_of_month
213
-
214
- # 9月の期間
215
- def all_september = ::Range.new(beginning_of_september, end_of_september)
216
-
217
- # 10月の月初
218
- def beginning_of_october = change(month: 10, day: 1) # steep:ignore NoMethod
219
-
220
- # 10月の月末
221
- def end_of_october = beginning_of_october.end_of_month
222
-
223
- # 10月の期間
224
- def all_october = ::Range.new(beginning_of_october, end_of_october)
225
-
226
- # 11月の月初
227
- def beginning_of_november = change(month: 11, day: 1) # steep:ignore NoMethod
228
-
229
- # 11月の月末
230
- def end_of_november = beginning_of_november.end_of_month
231
-
232
- # 11月の期間
233
- def all_november = ::Range.new(beginning_of_november, end_of_november)
234
-
235
- # 12月の月初
236
- def beginning_of_december = change(month: 12, day: 1) # steep:ignore NoMethod
237
-
238
- # 12月の月末
239
- def end_of_december = beginning_of_december.end_of_month
240
-
241
- # 12月の期間
242
- def all_december = ::Range.new(beginning_of_december, end_of_december)
243
-
244
- # ###############################################################################################################
245
- # 四半期関係
246
- # ###############################################################################################################
247
-
248
- # 第1四半期の始めの日付
249
- alias_method :beginning_of_first_quarter, :beginning_of_january
250
-
251
- # 第1四半期の終わりの日付
252
- alias_method :end_of_first_quarter, :end_of_march
253
-
254
- # 第1四半期の期間
255
- def all_first_quarter = ::Range.new(beginning_of_first_quarter, end_of_first_quarter)
256
-
257
- # 第2四半期の始めの日付
258
- alias_method :beginning_of_second_quarter, :beginning_of_april
259
-
260
- # 第2四半期の終わりの日付
261
- alias_method :end_of_second_quarter, :end_of_june
262
-
263
- # 第2四半期の期間
264
- def all_second_quarter = ::Range.new(beginning_of_second_quarter, end_of_second_quarter)
265
-
266
- # 第3四半期の始めの日付
267
- alias_method :beginning_of_third_quarter, :beginning_of_july
268
-
269
- # 第3四半期の終わりの日付
270
- alias_method :end_of_third_quarter, :end_of_september
271
-
272
- # 第3四半期の期間
273
- def all_third_quarter = ::Range.new(beginning_of_third_quarter, end_of_third_quarter)
274
-
275
- # 第4四半期の始めの日付
276
- alias_method :beginning_of_fourth_quarter, :beginning_of_october
277
-
278
- # 第4四半期の終わりの日付
279
- alias_method :end_of_fourth_quarter, :end_of_december
280
-
281
- # 第4四半期の期間
282
- def all_fourth_quarter = ::Range.new(beginning_of_fourth_quarter, end_of_fourth_quarter)
283
-
284
- # ###############################################################################################################
285
- # 上下期関係
286
- # ###############################################################################################################
287
-
288
- # 上期の始まりの日付
289
- alias_method :beginning_of_first_half, :beginning_of_first_quarter
290
-
291
- # 上期の終わりの日付
292
- alias_method :end_of_first_half, :end_of_second_quarter
293
-
294
- # 上期の期間
295
- def all_first_half = ::Range.new(beginning_of_first_half, end_of_first_half)
296
-
297
- # 下期の始まりの日付
298
- alias_method :beginning_of_second_half, :beginning_of_third_quarter
299
-
300
- # 下期の終わりの日付
301
- alias_method :end_of_second_half, :end_of_fourth_quarter
302
-
303
- # 下期の期間
304
- def all_second_half = ::Range.new(beginning_of_second_half, end_of_second_half)
305
- end
306
-
307
- refine ::Date.singleton_class do
308
- # ###############################################################################################################
309
- # 満経過月数
310
- # ###############################################################################################################
311
-
312
- # 満経過月数
313
- # steep:ignore:start
314
- def whole_months_elapsed(from:, to:)
315
- diff_year = to.year - from.year
316
- diff_month = to.month - from.month
317
-
318
- (diff_year * 12) + diff_month - (to.day >= from.day ? 0 : 1)
319
- end
320
- # steep:ignore:end
321
- end
322
- end
323
- end
3
+ require_relative "date_support/version"
4
+ require_relative "date_support/configuration"
5
+ require_relative "date_support/date_extension"
6
+ require_relative "date_support/date"
7
+ require_relative "date_support/time_extension"
8
+ require_relative "date_support/time"
9
+ require_relative "date_support/date_time"
10
+ require_relative "date_support/time_with_zone"
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "decentworks/date_support"
@@ -0,0 +1,26 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "rails/generators/base"
4
+
5
+ module Decentworks
6
+ module DateSupport
7
+ module Generators
8
+ # config/initializers/decentworks_date_support.rb を生成するジェネレータ
9
+ #
10
+ # @example
11
+ # bin/rails generate decentworks:date_support:install
12
+ class InstallGenerator < ::Rails::Generators::Base
13
+ source_root File.expand_path("templates", __dir__)
14
+
15
+ desc "config/initializers/decentworks_date_support.rb を生成します。"
16
+
17
+ def create_initializer_file
18
+ template(
19
+ "decentworks_date_support.rb.tt",
20
+ "config/initializers/decentworks_date_support.rb"
21
+ )
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ ::Decentworks::DateSupport.configure do |config|
4
+ # 第1四半期(上期)の開始月を指定します。
5
+ # 指定可能な値:
6
+ # :january # => 1月
7
+ # :february # => 2月
8
+ # :march # => 3月
9
+ # :april # => 4月
10
+ # :may # => 5月
11
+ # :june # => 6月
12
+ # :july # => 7月
13
+ # :august # => 8月
14
+ # :september # => 9月
15
+ # :october # => 10月
16
+ # :november # => 11月
17
+ # :december # => 12月
18
+
19
+ config.first_quarter_month_name = :january # 1月始まり
20
+ # 第1四半期:1月〜3月
21
+ # 第2四半期:4月〜6月
22
+ # 第3四半期:7月〜9月
23
+ # 第4四半期:10月〜12月
24
+ # 上期:1月〜6月
25
+ # 下期:7月〜12月
26
+
27
+ # config.first_quarter_month_name = :april # 4月始まり
28
+ # 第1四半期:4月〜6月
29
+ # 第2四半期:7月〜9月
30
+ # 第3四半期:10月〜12月
31
+ # 第4四半期:翌1月〜翌3月
32
+ # 上期:4月〜9月
33
+ # 下期:10月〜翌3月
34
+
35
+ # config.first_quarter_month_name = :july # 7月始まり
36
+ # 第1四半期:7月〜9月
37
+ # 第2四半期:10月〜12月
38
+ # 第3四半期:翌1月〜翌3月
39
+ # 第4四半期:翌4月〜翌6月
40
+ # 上期:7月〜12月
41
+ # 下期:翌1月〜翌6月
42
+
43
+ # config.first_quarter_month_name = :october # 10月始まり
44
+ # 第1四半期:10月〜12月
45
+ # 第2四半期:翌1月〜翌3月
46
+ # 第3四半期:翌4月〜翌6月
47
+ # 第4四半期:翌7月〜翌9月
48
+ # 上期:10月〜翌3月
49
+ # 下期:翌4月〜翌9月
50
+ end
@@ -0,0 +1,25 @@
1
+ module Decentworks
2
+ module DateSupport
3
+ def self.configure: () ?{ (::Decentworks::DateSupport::Configuration) -> void } -> void
4
+ def self.configuration: -> ::Decentworks::DateSupport::Configuration
5
+
6
+ def self.reset_configuration!: -> nil
7
+
8
+ def self.first_quarter_month_name: -> Symbol
9
+ def self.first_quarter_month: -> Integer
10
+ def self.first_quarter_month_offset: -> Integer
11
+
12
+ class Configuration
13
+ MONTHS: Hash[Symbol, Integer]
14
+ DEFAULT: Symbol
15
+
16
+ attr_reader first_quarter_month_name: Symbol
17
+
18
+ def first_quarter_month_name=: (Symbol) -> void
19
+
20
+ def first_quarter_month: -> Integer
21
+
22
+ def first_quarter_month_offset: -> Integer
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,4 @@
1
+ class Date
2
+ include ::Decentworks::DateSupport::DateExtension
3
+ extend ::Decentworks::DateSupport::DateExtension::ClassMethods
4
+ end