decentworks-date-support 0.1.1 → 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 (34) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +81 -0
  3. data/LICENSE +1 -1
  4. data/README.md +245 -40
  5. data/lib/decentworks/date_support/configuration.rb +19 -18
  6. data/lib/decentworks/date_support/date.rb +4 -541
  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 +1 -1
  13. data/lib/decentworks/date_support.rb +5 -1
  14. data/lib/generators/decentworks/date_support/install/templates/decentworks_date_support.rb.tt +4 -6
  15. data/sig/decentworks/date_support/configuration.rbs +12 -3
  16. data/sig/decentworks/date_support/date.rbs +3 -167
  17. data/sig/decentworks/date_support/date_extension.rbs +244 -0
  18. data/sig/decentworks/date_support/date_time.rbs +4 -0
  19. data/sig/decentworks/date_support/time.rbs +4 -0
  20. data/sig/decentworks/date_support/time_extension.rbs +248 -0
  21. data/sig/decentworks/date_support/time_with_zone.rbs +21 -0
  22. data/sig/decentworks/date_support/version.rbs +5 -0
  23. metadata +14 -13
  24. data/.rspec +0 -3
  25. data/.rubocop.yml +0 -8
  26. data/.ruby-version +0 -1
  27. data/CODE_OF_CONDUCT.md +0 -132
  28. data/LICENSE.txt +0 -21
  29. data/Rakefile +0 -12
  30. data/Steepfile +0 -43
  31. data/lib/decentworks/active_support/time_with_zone_support.rb +0 -541
  32. data/rbs_collection.lock.yaml +0 -288
  33. data/rbs_collection.yaml +0 -41
  34. data/sig/decentworks/active_support/time_with_zone_support.rbs +0 -163
@@ -1,541 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require "date"
4
- require "active_support/time"
5
- require_relative "../date_support/date" # using ::Decentworks::DateSupport に必要
6
-
7
- module Decentworks
8
- module ActiveSupport
9
- module TimeWithZoneSupport
10
- using ::Decentworks::DateSupport
11
-
12
- refine ::ActiveSupport::TimeWithZone do
13
- # #############################################################################################################
14
- # 週関係
15
- # #############################################################################################################
16
-
17
- #
18
- # 今週
19
- #
20
-
21
- # 現在の日付が属する週の始まりの日付
22
- def beginning_of_this_week = to_date.beginning_of_this_week.beginning_of_day
23
-
24
- # 現在の日付が属する週の終わりの日付
25
- def end_of_this_week = to_date.next_week.beginning_of_this_week.yesterday.end_of_day
26
-
27
- # 今週の期間
28
- def all_this_week = ::Range.new(beginning_of_this_week, end_of_this_week)
29
-
30
- # #############################################################################################################
31
- # 月関係
32
- # #############################################################################################################
33
-
34
- #
35
- # 今月関係
36
- #
37
-
38
- # 現在の日付が属する月の期間
39
- def all_this_month = ::Range.new(beginning_of_month, end_of_month) # steep:ignore NoMethod
40
-
41
- #
42
- # Nヶ月前関係
43
- #
44
-
45
- # 2ヶ月前の日付
46
- def two_months_ago = months_ago(2) # steep:ignore NoMethod
47
-
48
- # 3ヶ月前の日付
49
- def three_months_ago = months_ago(3) # steep:ignore NoMethod
50
-
51
- # 4ヶ月前の日付
52
- def four_months_ago = months_ago(4) # steep:ignore NoMethod
53
-
54
- # 5ヶ月前の日付
55
- def five_months_ago = months_ago(5) # steep:ignore NoMethod
56
-
57
- # 6ヶ月前の日付
58
- def six_months_ago = months_ago(6) # steep:ignore NoMethod
59
-
60
- # 半年前の日
61
- alias_method :half_year_ago, :six_months_ago
62
-
63
- # 7ヶ月前の日付
64
- def seven_months_ago = months_ago(7) # steep:ignore NoMethod
65
-
66
- # 8ヶ月前の日付
67
- def eight_months_ago = months_ago(8) # steep:ignore NoMethod
68
-
69
- # 9ヶ月前の日付
70
- def nine_months_ago = months_ago(9) # steep:ignore NoMethod
71
-
72
- # 10ヶ月前の日付
73
- def ten_months_ago = months_ago(10) # steep:ignore NoMethod
74
-
75
- # 11ヶ月前の日付
76
- def eleven_months_ago = months_ago(11) # steep:ignore NoMethod
77
-
78
- #
79
- # Nヶ月後関係
80
- #
81
-
82
- # 2ヶ月後の日付
83
- def two_months_since = months_since(2) # steep:ignore NoMethod
84
-
85
- # 3ヶ月後の日付
86
- def three_months_since = months_since(3) # steep:ignore NoMethod
87
-
88
- # 4ヶ月後の日付
89
- def four_months_since = months_since(4) # steep:ignore NoMethod
90
-
91
- # 5ヶ月後の日付
92
- def five_months_since = months_since(5) # steep:ignore NoMethod
93
-
94
- # 6ヶ月後の日付
95
- def six_months_since = months_since(6) # steep:ignore NoMethod
96
-
97
- # 半年前の日
98
- alias_method :half_year_since, :six_months_since
99
-
100
- # 7ヶ月後の日付
101
- def seven_months_since = months_since(7) # steep:ignore NoMethod
102
-
103
- # 8ヶ月後の日付
104
- def eight_months_since = months_since(8) # steep:ignore NoMethod
105
-
106
- # 9ヶ月後の日付
107
- def nine_months_since = months_since(9) # steep:ignore NoMethod
108
-
109
- # 10ヶ月後の日付
110
- def ten_months_since = months_since(10) # steep:ignore NoMethod
111
-
112
- # 11ヶ月後の日付
113
- def eleven_months_since = months_since(11) # steep:ignore NoMethod
114
-
115
- #
116
- # 暦月関係
117
- #
118
-
119
- #
120
- # 1月
121
- #
122
-
123
- # 1月の月初
124
- def beginning_of_january = to_date.beginning_of_january.beginning_of_day # steep:ignore NoMethod
125
-
126
- # 1月の月末
127
- def end_of_january = beginning_of_january.end_of_month.end_of_day
128
-
129
- # 1月の期間
130
- def all_january = ::Range.new(beginning_of_january, end_of_january)
131
-
132
- # 1月の月初か?
133
- def beginning_of_january? = beginning_of_january.all_day.cover?(self)
134
-
135
- # 1月の月末か?
136
- def end_of_january? = end_of_january.all_day.cover?(self)
137
-
138
- # 1月か?
139
- def in_january? = all_january.cover?(self)
140
-
141
- #
142
- # 2月
143
- #
144
-
145
- # 2月の月初
146
- def beginning_of_february = to_date.beginning_of_february.beginning_of_day # steep:ignore NoMethod
147
-
148
- # 2月の月末
149
- def end_of_february = beginning_of_february.end_of_month.end_of_day
150
-
151
- # 2月の期間
152
- def all_february = ::Range.new(beginning_of_february, end_of_february)
153
-
154
- # 2月の月初か?
155
- def beginning_of_february? = beginning_of_february.all_day.cover?(self)
156
-
157
- # 2月の月末か?
158
- def end_of_february? = end_of_february.all_day.cover?(self)
159
-
160
- # 2月か?
161
- def in_february? = all_february.cover?(self)
162
-
163
- #
164
- # 3月
165
- #
166
-
167
- # 3月の月初
168
- def beginning_of_march = to_date.beginning_of_march.beginning_of_day # steep:ignore NoMethod
169
-
170
- # 3月の月末
171
- def end_of_march = beginning_of_march.end_of_month.end_of_day
172
-
173
- # 3月の期間
174
- def all_march = ::Range.new(beginning_of_march, end_of_march)
175
-
176
- # 3月の月初か?
177
- def beginning_of_march? = beginning_of_march.all_day.cover?(self)
178
-
179
- # 3月の月末か?
180
- def end_of_march? = end_of_march.all_day.cover?(self)
181
-
182
- # 3月か?
183
- def in_march? = all_march.cover?(self)
184
-
185
- #
186
- # 4月
187
- #
188
-
189
- # 4月の月初
190
- def beginning_of_april = to_date.beginning_of_april.beginning_of_day # steep:ignore NoMethod
191
-
192
- # 4月の月末
193
- def end_of_april = beginning_of_april.end_of_month.end_of_day
194
-
195
- # 4月の期間
196
- def all_april = ::Range.new(beginning_of_april, end_of_april)
197
-
198
- # 4月の月初か?
199
- def beginning_of_april? = beginning_of_april.all_day.cover?(self)
200
-
201
- # 4月の月末か?
202
- def end_of_april? = end_of_april.all_day.cover?(self)
203
-
204
- # 4月か?
205
- def in_april? = all_april.cover?(self)
206
-
207
- #
208
- # 5月
209
- #
210
-
211
- # 5月の月初
212
- def beginning_of_may = to_date.beginning_of_may.beginning_of_day # steep:ignore NoMethod
213
-
214
- # 5月の月末
215
- def end_of_may = beginning_of_may.end_of_month.end_of_day
216
-
217
- # 5月の期間
218
- def all_may = ::Range.new(beginning_of_may, end_of_may)
219
-
220
- # 5月の月初か?
221
- def beginning_of_may? = beginning_of_may.all_day.cover?(self)
222
-
223
- # 5月の月末か?
224
- def end_of_may? = end_of_may.all_day.cover?(self)
225
-
226
- # 5月か?
227
- def in_may? = all_may.cover?(self)
228
-
229
- #
230
- # 6月
231
- #
232
-
233
- # 6月の月初
234
- def beginning_of_june = to_date.beginning_of_june.beginning_of_day # steep:ignore NoMethod
235
-
236
- # 6月の月末
237
- def end_of_june = beginning_of_june.end_of_month.end_of_day
238
-
239
- # 6月の期間
240
- def all_june = ::Range.new(beginning_of_june, end_of_june)
241
-
242
- # 6月の月初か?
243
- def beginning_of_june? = beginning_of_june.all_day.cover?(self)
244
-
245
- # 6月の月末か?
246
- def end_of_june? = end_of_june.all_day.cover?(self)
247
-
248
- # 6月か?
249
- def in_june? = all_june.cover?(self)
250
-
251
- #
252
- # 7月
253
- #
254
-
255
- # 7月の月初
256
- def beginning_of_july = to_date.beginning_of_july.beginning_of_day # steep:ignore NoMethod
257
-
258
- # 7月の月末
259
- def end_of_july = beginning_of_july.end_of_month.end_of_day
260
-
261
- # 7月の期間
262
- def all_july = ::Range.new(beginning_of_july, end_of_july)
263
-
264
- # 7月の月初か?
265
- def beginning_of_july? = beginning_of_july.all_day.cover?(self)
266
-
267
- # 7月の月末か?
268
- def end_of_july? = end_of_july.all_day.cover?(self)
269
-
270
- # 7月か?
271
- def in_july? = all_july.cover?(self)
272
-
273
- #
274
- # 8月
275
- #
276
-
277
- # 8月の月初
278
- def beginning_of_august = to_date.beginning_of_august.beginning_of_day # steep:ignore NoMethod
279
-
280
- # 8月の月末
281
- def end_of_august = beginning_of_august.end_of_month.end_of_day
282
-
283
- # 8月の期間
284
- def all_august = ::Range.new(beginning_of_august, end_of_august)
285
-
286
- # 8月の月初か?
287
- def beginning_of_august? = beginning_of_august.all_day.cover?(self)
288
-
289
- # 8月の月末か?
290
- def end_of_august? = end_of_august.all_day.cover?(self)
291
-
292
- # 8月か?
293
- def in_august? = all_august.cover?(self)
294
-
295
- #
296
- # 9月
297
- #
298
-
299
- # 9月の月初
300
- def beginning_of_september = to_date.beginning_of_september.beginning_of_day # steep:ignore NoMethod
301
-
302
- # 9月の月末
303
- def end_of_september = beginning_of_september.end_of_month.end_of_day
304
-
305
- # 9月の期間
306
- def all_september = ::Range.new(beginning_of_september, end_of_september)
307
-
308
- # 9月の月初か?
309
- def beginning_of_september? = beginning_of_september.all_day.cover?(self)
310
-
311
- # 9月の月末か?
312
- def end_of_september? = end_of_september.all_day.cover?(self)
313
-
314
- # 9月か?
315
- def in_september? = all_september.cover?(self)
316
-
317
- #
318
- # 10月
319
- #
320
-
321
- # 10月の月初
322
- def beginning_of_october = to_date.beginning_of_october.beginning_of_day # steep:ignore NoMethod
323
-
324
- # 10月の月末
325
- def end_of_october = beginning_of_october.end_of_month.end_of_day
326
-
327
- # 10月の期間
328
- def all_october = ::Range.new(beginning_of_october, end_of_october)
329
-
330
- # 10月の月初か?
331
- def beginning_of_october? = beginning_of_october.all_day.cover?(self)
332
-
333
- # 10月の月末か?
334
- def end_of_october? = end_of_october.all_day.cover?(self)
335
-
336
- # 10月か?
337
- def in_october? = all_october.cover?(self)
338
-
339
- #
340
- # 11月
341
- #
342
-
343
- # 11月の月初
344
- def beginning_of_november = to_date.beginning_of_november.beginning_of_day # steep:ignore NoMethod
345
-
346
- # 11月の月末
347
- def end_of_november = beginning_of_november.end_of_month.end_of_day
348
-
349
- # 11月の期間
350
- def all_november = ::Range.new(beginning_of_november, end_of_november)
351
-
352
- # 11月の月初か?
353
- def beginning_of_november? = beginning_of_november.all_day.cover?(self)
354
-
355
- # 11月の月末か?
356
- def end_of_november? = end_of_november.all_day.cover?(self)
357
-
358
- # 11月か?
359
- def in_november? = all_november.cover?(self)
360
-
361
- #
362
- # 12月
363
- #
364
-
365
- # 12月の月初
366
- def beginning_of_december = to_date.beginning_of_december.beginning_of_day # steep:ignore NoMethod
367
-
368
- # 12月の月末
369
- def end_of_december = beginning_of_december.end_of_month.end_of_day
370
-
371
- # 12月の期間
372
- def all_december = ::Range.new(beginning_of_december, end_of_december)
373
-
374
- # 12月の月初か?
375
- def beginning_of_december? = beginning_of_december.all_day.cover?(self)
376
-
377
- # 12月の月末か?
378
- def end_of_december? = end_of_december.all_day.cover?(self)
379
-
380
- # 12月か?
381
- def in_december? = all_december.cover?(self)
382
-
383
- # #############################################################################################################
384
- # 四半期関係
385
- # #############################################################################################################
386
-
387
- #
388
- # 第1四半期
389
- #
390
-
391
- # 第1四半期の期首
392
- def beginning_of_first_quarter = to_date.beginning_of_first_quarter.beginning_of_day
393
-
394
- # 第1四半期の期末
395
- def end_of_first_quarter = to_date.end_of_first_quarter.end_of_day
396
-
397
- # 第1四半期の期間
398
- def all_first_quarter = ::Range.new(beginning_of_first_quarter, end_of_first_quarter)
399
-
400
- # 第1四半期の期首か?
401
- def beginning_of_first_quarter? = beginning_of_first_quarter.all_day.cover?(self)
402
-
403
- # 第1四半期の期末か?
404
- def end_of_first_quarter? = end_of_first_quarter.all_day.cover?(self)
405
-
406
- # 第1四半期か?
407
- def in_first_quarter? = all_first_quarter.cover?(self)
408
-
409
- #
410
- # 第2四半期
411
- #
412
-
413
- # 第2四半期の期首
414
- def beginning_of_second_quarter = to_date.beginning_of_second_quarter.beginning_of_day
415
-
416
- # 第2四半期の期末
417
- def end_of_second_quarter = to_date.end_of_second_quarter.end_of_day
418
-
419
- # 第2四半期の期間
420
- def all_second_quarter = ::Range.new(beginning_of_second_quarter, end_of_second_quarter)
421
-
422
- # 第2四半期の期首か?
423
- def beginning_of_second_quarter? = beginning_of_second_quarter.all_day.cover?(self)
424
-
425
- # 第2四半期の期末か?
426
- def end_of_second_quarter? = end_of_second_quarter.all_day.cover?(self)
427
-
428
- # 第2四半期か?
429
- def in_second_quarter? = all_second_quarter.cover?(self)
430
-
431
- #
432
- # 第3四半期
433
- #
434
-
435
- # 第3四半期の期首
436
- def beginning_of_third_quarter = to_date.beginning_of_third_quarter.beginning_of_day
437
-
438
- # 第3四半期の期末
439
- def end_of_third_quarter = to_date.end_of_third_quarter.end_of_day
440
-
441
- # 第3四半期の期間
442
- def all_third_quarter = ::Range.new(beginning_of_third_quarter, end_of_third_quarter)
443
-
444
- # 第3四半期の期首か?
445
- def beginning_of_third_quarter? = beginning_of_third_quarter.all_day.cover?(self)
446
-
447
- # 第3四半期の期末か?
448
- def end_of_third_quarter? = end_of_third_quarter.all_day.cover?(self)
449
-
450
- # 第3四半期か?
451
- def in_third_quarter? = all_third_quarter.cover?(self)
452
-
453
- #
454
- # 第4四半期
455
- #
456
-
457
- # 第4四半期の期首
458
- def beginning_of_fourth_quarter = to_date.beginning_of_fourth_quarter.beginning_of_day
459
-
460
- # 第4四半期の期末
461
- def end_of_fourth_quarter = to_date.end_of_fourth_quarter.end_of_day
462
-
463
- # 第4四半期の期間
464
- def all_fourth_quarter = ::Range.new(beginning_of_fourth_quarter, end_of_fourth_quarter)
465
-
466
- # 第4四半期の期首か?
467
- def beginning_of_fourth_quarter? = beginning_of_fourth_quarter.all_day.cover?(self)
468
-
469
- # 第4四半期の期末か?
470
- def end_of_fourth_quarter? = end_of_fourth_quarter.all_day.cover?(self)
471
-
472
- # 第4四半期か?
473
- def in_fourth_quarter? = all_fourth_quarter.cover?(self)
474
-
475
- # #############################################################################################################
476
- # 上下期関係
477
- # #############################################################################################################
478
-
479
- #
480
- # 上期
481
- #
482
-
483
- # 上期の期首
484
- alias_method :beginning_of_first_half, :beginning_of_first_quarter
485
-
486
- # 上期の期末
487
- alias_method :end_of_first_half, :end_of_second_quarter
488
-
489
- # 上期の期間
490
- def all_first_half = ::Range.new(beginning_of_first_half, end_of_first_half)
491
-
492
- # 上期の期首か?
493
- def beginning_of_first_half? = beginning_of_first_half.all_day.cover?(self)
494
-
495
- # 上期の期末か?
496
- def end_of_first_half? = end_of_first_half.all_day.cover?(self)
497
-
498
- # 上期か?
499
- def in_first_half? = all_first_half.cover?(self)
500
-
501
- #
502
- # 下期
503
- #
504
-
505
- # 下期の期首
506
- alias_method :beginning_of_second_half, :beginning_of_third_quarter
507
-
508
- # 下期の期末
509
- alias_method :end_of_second_half, :end_of_fourth_quarter
510
-
511
- # 下期の期間
512
- def all_second_half = ::Range.new(beginning_of_second_half, end_of_second_half)
513
-
514
- # 下期の期首か?
515
- def beginning_of_second_half? = beginning_of_second_half.all_day.cover?(self)
516
-
517
- # 下期の期末か?
518
- def end_of_second_half? = end_of_second_half.all_day.cover?(self)
519
-
520
- # 下期か?
521
- def in_second_half? = all_second_half.cover?(self)
522
- end
523
-
524
- refine ::ActiveSupport::TimeWithZone.singleton_class do
525
- # #############################################################################################################
526
- # 満経過月数
527
- # #############################################################################################################
528
-
529
- # 満経過月数
530
- # steep:ignore:start
531
- def whole_months_elapsed(from:, to:)
532
- ::Date.whole_months_elapsed(
533
- from: from.to_date,
534
- to: to.to_date
535
- )
536
- end
537
- # steep:ignore:end
538
- end
539
- end
540
- end
541
- end