fat_date 0.1.0 → 0.1.4
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 +4 -4
- data/.rubocop.yml +3 -9
- data/CHANGELOG.org +5 -3
- data/README.org +93 -54
- data/Rakefile +17 -3
- data/lib/fat_date/date.rb +6 -9
- data/lib/fat_date/datetime.rb +15 -0
- data/lib/fat_date/version.rb +1 -1
- data/lib/fat_date.rb +1 -4
- metadata +18 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 452b9656245ca0f24843e11235d7dd515d3d2e45c3900997770cc5ebaca634f8
|
|
4
|
+
data.tar.gz: 0b4cb43b3a743b1086f51002caa6264a980e6dc08d8c0154d39a16514ed60a27
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 81ad8559c9c4663fa7c65fa0d27bc649a48cb9083f3c50517cc01e55e1ee765fd5b47a7125736a85fc396c1cf38016a1c528873dabab713a94dd67417fde2945
|
|
7
|
+
data.tar.gz: b4de5c7866c14cb16d8b5d5bd8f4ee80d0e8f37c6b059666766a3c9916b2d2394d6fd38e332c3dd78c99e907501a2407f4fd2a9d7c20b27c8d86d673fc5f1484
|
data/.rubocop.yml
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
AllCops:
|
|
5
|
-
NewCops: enable
|
|
6
|
-
TargetRubyVersion: 3.0
|
|
7
|
-
|
|
8
|
-
Style/BitwisePredicate:
|
|
9
|
-
Enabled: false
|
|
1
|
+
# Inherit the shared config from the rubocop-ddoherty gem (git-hosted on GitHub)
|
|
2
|
+
inherit_gem:
|
|
3
|
+
rubocop-ddoherty: 'config/default.yml'
|
data/CHANGELOG.org
CHANGED
data/README.org
CHANGED
|
@@ -1,45 +1,105 @@
|
|
|
1
1
|
#+TITLE: FatDate Guide
|
|
2
2
|
#+OPTIONS: toc:5
|
|
3
|
-
#+PROPERTY: header-args:ruby :colnames no :hlines yes :exports both :wrap example :ruby
|
|
3
|
+
#+PROPERTY: header-args:ruby :colnames no :session fatdate :hlines yes :exports both :wrap example :ruby "bundle exec irb --prompt=simple"
|
|
4
4
|
#+PROPERTY: header-args:sh :exports code
|
|
5
5
|
|
|
6
|
-
[[https://travis-ci.org/ddoherty03/fat_core.svg?branch=master]]
|
|
7
6
|
|
|
8
|
-
|
|
7
|
+
[[https://github.com/ddoherty03/fat_date/actions/workflows/ruby.yml][https://github.com/ddoherty03/fat_date/actions/workflows/ruby.yml/badge.svg?branch=master]]
|
|
8
|
+
|
|
9
|
+
,#+BEGIN_COMMENT
|
|
10
|
+
|
|
11
|
+
* Setup for Code Blocks :noexport:
|
|
9
12
|
Run this block before all others to ensure that we are reading the libraries
|
|
10
13
|
from the source directory.
|
|
11
14
|
|
|
12
15
|
#+begin_src ruby :results output :export no
|
|
13
16
|
puts "Current directory: #{Dir.pwd}"
|
|
14
17
|
puts "Ruby LOADPATH:"
|
|
15
|
-
|
|
18
|
+
$LOAD_PATH.unshift(File.expand_path("lib", Dir.pwd)) unless $:[0].match?(%r{src/fat_date/lib})
|
|
16
19
|
$:[0..10].each { |d| puts d }
|
|
17
20
|
puts "..."
|
|
18
|
-
require 'fat_date'
|
|
21
|
+
require 'fat_date'
|
|
19
22
|
#+end_src
|
|
20
23
|
|
|
21
24
|
#+RESULTS:
|
|
22
25
|
#+begin_example
|
|
23
26
|
Current directory: /home/ded/src/fat_date
|
|
24
27
|
Ruby LOADPATH:
|
|
25
|
-
|
|
28
|
+
/home/ded/src/fat_date/lib
|
|
29
|
+
/home/ded/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/bundler-2.6.7/lib
|
|
26
30
|
/home/ded/.rbenv/rbenv.d/exec/gem-rehash
|
|
27
|
-
/home/ded/.rbenv/versions/3.4.1/lib/ruby/
|
|
28
|
-
/home/ded/.rbenv/versions/3.4.1/lib/ruby/
|
|
29
|
-
/home/ded/.rbenv/versions/3.4.1/lib/ruby/
|
|
30
|
-
/home/ded/.rbenv/versions/3.4.1/lib/ruby/
|
|
31
|
-
/home/ded/.rbenv/versions/3.4.1/lib/ruby/
|
|
32
|
-
/home/ded/.rbenv/versions/3.4.1/lib/ruby/
|
|
33
|
-
/home/ded/.rbenv/versions/3.4.1/lib/ruby/3.4.0
|
|
34
|
-
/home/ded/.rbenv/versions/3.4.1/lib/ruby/3.4.0/
|
|
31
|
+
/home/ded/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/simplecov-0.22.0/lib
|
|
32
|
+
/home/ded/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/simplecov_json_formatter-0.1.4/lib
|
|
33
|
+
/home/ded/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/simplecov-html-0.13.2/lib
|
|
34
|
+
/home/ded/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/bundler/gems/rubocop-ddoherty-6b28e9614f18/lib
|
|
35
|
+
/home/ded/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/rubocop-shopify-2.17.1/lib
|
|
36
|
+
/home/ded/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/rubocop-rspec-3.7.0/lib
|
|
37
|
+
/home/ded/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/rubocop-rake-0.7.1/lib
|
|
38
|
+
/home/ded/.rbenv/versions/3.4.1/lib/ruby/gems/3.4.0/gems/rubocop-performance-1.26.1/lib
|
|
35
39
|
...
|
|
36
40
|
#+end_example
|
|
37
41
|
|
|
42
|
+
,#+END_COMMENT
|
|
43
|
+
|
|
44
|
+
* Table of Contents :toc:
|
|
45
|
+
- [[#fatdate][FatDate]]
|
|
46
|
+
- [[#version][Version]]
|
|
47
|
+
- [[#installation][Installation]]
|
|
48
|
+
- [[#usage][Usage]]
|
|
49
|
+
- [[#constants][Constants]]
|
|
50
|
+
- [[#ensure][Ensure]]
|
|
51
|
+
- [[#formatting][Formatting]]
|
|
52
|
+
- [[#chunks][Chunks]]
|
|
53
|
+
- [[#parsing-american-dates][Parsing American Dates]]
|
|
54
|
+
- [[#holidays-and-workdays][Holidays and Workdays]]
|
|
55
|
+
- [[#federal][Federal]]
|
|
56
|
+
- [[#nyse][NYSE]]
|
|
57
|
+
- [[#ordinal-weekdays-in-month][Ordinal Weekdays in Month]]
|
|
58
|
+
- [[#easter][Easter]]
|
|
59
|
+
- [[#date-specs][Date Specs]]
|
|
60
|
+
- [[#given-day][Given Day]]
|
|
61
|
+
- [[#day-of-year][Day-of-Year]]
|
|
62
|
+
- [[#month][Month]]
|
|
63
|
+
- [[#year][Year]]
|
|
64
|
+
- [[#commercial-weeks-of-year][Commercial Weeks-of-Year]]
|
|
65
|
+
- [[#halves][Halves]]
|
|
66
|
+
- [[#quarters][Quarters]]
|
|
67
|
+
- [[#semi-months][Semi-Months]]
|
|
68
|
+
- [[#week-of-month][Week-of-Month]]
|
|
69
|
+
- [[#day-of-week][Day-of-Week]]
|
|
70
|
+
- [[#easter-based][Easter Based]]
|
|
71
|
+
- [[#relative-dates][Relative Dates]]
|
|
72
|
+
- [[#extremes][Extremes]]
|
|
73
|
+
- [[#skip-modifiers][Skip Modifiers]]
|
|
74
|
+
- [[#conventions][Conventions]]
|
|
75
|
+
- [[#examples][Examples]]
|
|
76
|
+
- [[#contributing][Contributing]]
|
|
38
77
|
|
|
39
78
|
* FatDate
|
|
79
|
+
~fat_date~ collects core extensions for the Date class to make it more useful
|
|
80
|
+
in financial applications, including:
|
|
81
|
+
|
|
82
|
+
- determining when a =Date= is a federal or NYSE holiday with Presidential
|
|
83
|
+
decrees included,
|
|
84
|
+
- determining when a =Date= is part of a larger calendar-related "chunk," such
|
|
85
|
+
as a year, half, quarter, bimonth, month, semimonth, or week,
|
|
86
|
+
- calculating Easter for a =Date's= year, a date on which some "movable
|
|
87
|
+
feasts" depend, and
|
|
88
|
+
- parsing so-called "specs" that allow the beginning or ending =Date= of a
|
|
89
|
+
larger period of time to be returned, a facility put to good use in the
|
|
90
|
+
[[https://github.com/ddoherty03/fat_period][FatPeriod]] gem.
|
|
91
|
+
|
|
92
|
+
|
|
93
|
+
* Version
|
|
94
|
+
|
|
95
|
+
#+begin_src ruby :results output
|
|
96
|
+
puts "#{FatDate::VERSION}"
|
|
97
|
+
#+end_src
|
|
98
|
+
|
|
99
|
+
#+begin_example
|
|
100
|
+
0.1.3
|
|
101
|
+
#+end_example
|
|
40
102
|
|
|
41
|
-
~fat_date~ is a simple gem to collect core extensions for the Date class to
|
|
42
|
-
make it more useful in financial applications.
|
|
43
103
|
|
|
44
104
|
* Installation
|
|
45
105
|
|
|
@@ -58,7 +118,7 @@ And then execute:
|
|
|
58
118
|
Or install it yourself as:
|
|
59
119
|
|
|
60
120
|
#+begin_src shell
|
|
61
|
-
$ gem install
|
|
121
|
+
$ gem install fat_date
|
|
62
122
|
#+end_src
|
|
63
123
|
|
|
64
124
|
* Usage
|
|
@@ -87,9 +147,7 @@ a date argument but want the caller to be able to supply anything that can
|
|
|
87
147
|
reasonably be converted to a ~Date~:
|
|
88
148
|
|
|
89
149
|
#+begin_src ruby :results output
|
|
90
|
-
|
|
91
|
-
require 'fat_core/date' # => true
|
|
92
|
-
|
|
150
|
+
# require 'fat_date'
|
|
93
151
|
def tomorow_tomorrow(arg)
|
|
94
152
|
from = Date.ensure(arg) # => ArgumentError: cannot convert class 'Array' to a Date or DateTime
|
|
95
153
|
from + 2.days # => Mon, 03 Jun 2024, Wed, 16 Oct 2024 05:47:30 -0500, Sun, 03 Mar 2024
|
|
@@ -104,7 +162,7 @@ reasonably be converted to a ~Date~:
|
|
|
104
162
|
|
|
105
163
|
#+begin_example
|
|
106
164
|
2025-06-03
|
|
107
|
-
2025-10-
|
|
165
|
+
2025-10-26T15:42:14-05:00
|
|
108
166
|
2025-03-03
|
|
109
167
|
#+end_example
|
|
110
168
|
|
|
@@ -113,7 +171,6 @@ reasonably be converted to a ~Date~:
|
|
|
113
171
|
that are often useful:
|
|
114
172
|
|
|
115
173
|
#+begin_SRC ruby :results output
|
|
116
|
-
require_relative './lib/fat_date'
|
|
117
174
|
d = Date.parse('1957-09-22')
|
|
118
175
|
puts "ISO: #{d.iso}"
|
|
119
176
|
puts "All Numbers: #{d.num}"
|
|
@@ -134,6 +191,7 @@ English: September 22, 1957
|
|
|
134
191
|
American: 9/22/1957
|
|
135
192
|
#+end_example
|
|
136
193
|
|
|
194
|
+
|
|
137
195
|
Most of these are self-explanatory, but a couple are not. The
|
|
138
196
|
~Date.org(active: false)~ method formats a date as an Emacs org-mode
|
|
139
197
|
timestamp, by default an inactive timestamp that does not show up in the org
|
|
@@ -163,8 +221,6 @@ as "chunks", and they are the following:
|
|
|
163
221
|
or end of each of these chunks:
|
|
164
222
|
|
|
165
223
|
#+begin_SRC ruby :results value
|
|
166
|
-
require_relative './lib/fat_date'
|
|
167
|
-
|
|
168
224
|
tab = []
|
|
169
225
|
tab << ['Subject Date', 'Method', 'Result']
|
|
170
226
|
tab << nil
|
|
@@ -203,8 +259,6 @@ It also provides corresponding methods that return the date at the beginning
|
|
|
203
259
|
or end of the calendar chunk, starting at the given date:
|
|
204
260
|
|
|
205
261
|
#+begin_SRC ruby
|
|
206
|
-
require './lib/fat_date'
|
|
207
|
-
|
|
208
262
|
tab = []
|
|
209
263
|
tab << ['Subject Date', 'Method', 'Result']
|
|
210
264
|
tab << nil
|
|
@@ -239,11 +293,10 @@ or end of the calendar chunk, starting at the given date:
|
|
|
239
293
|
| 2017-04-21 | d.end_of_week | 2017-04-23 |
|
|
240
294
|
#+end_example
|
|
241
295
|
|
|
296
|
+
|
|
242
297
|
You can query which numerical half, quarter, etc. that a given date falls in:
|
|
243
298
|
|
|
244
299
|
#+begin_SRC ruby
|
|
245
|
-
require './lib/fat_date'
|
|
246
|
-
|
|
247
300
|
tab = []
|
|
248
301
|
tab << ['Subject Date', 'Method', 'Result']
|
|
249
302
|
tab << nil
|
|
@@ -258,14 +311,14 @@ You can query which numerical half, quarter, etc. that a given date falls in:
|
|
|
258
311
|
#+begin_example
|
|
259
312
|
| Subject Date | Method | Result |
|
|
260
313
|
|--------------+-------------+------------------------|
|
|
261
|
-
| 2017-07-
|
|
262
|
-
| 2017-06-
|
|
263
|
-
| 2017-07-
|
|
264
|
-
| 2017-
|
|
265
|
-
| 2017-
|
|
266
|
-
| 2017-
|
|
267
|
-
| 2017-05-
|
|
268
|
-
| 2017-07-
|
|
314
|
+
| 2017-07-29 | d.year | in year number 2017 |
|
|
315
|
+
| 2017-06-10 | d.half | in half number 1 |
|
|
316
|
+
| 2017-07-17 | d.quarter | in quarter number 3 |
|
|
317
|
+
| 2017-06-03 | d.bimonth | in bimonth number 3 |
|
|
318
|
+
| 2017-06-28 | d.month | in month number 6 |
|
|
319
|
+
| 2017-06-18 | d.semimonth | in semimonth number 12 |
|
|
320
|
+
| 2017-05-17 | d.biweek | in biweek number 10 |
|
|
321
|
+
| 2017-07-08 | d.week | in week number 27 |
|
|
269
322
|
#+end_example
|
|
270
323
|
|
|
271
324
|
*** Parsing American Dates
|
|
@@ -275,8 +328,6 @@ will parse such a string as d/M/Y, often resulting in invalid date errors.
|
|
|
275
328
|
such strings.
|
|
276
329
|
|
|
277
330
|
#+begin_SRC ruby :results output
|
|
278
|
-
require './lib/fat_date'
|
|
279
|
-
|
|
280
331
|
begin
|
|
281
332
|
ss = '9/22/1957'
|
|
282
333
|
Date.parse(ss)
|
|
@@ -320,9 +371,6 @@ Methods concerning Federal holidays:
|
|
|
320
371
|
we hit a Federal workday
|
|
321
372
|
|
|
322
373
|
#+begin_SRC ruby
|
|
323
|
-
require './lib/fat_date'
|
|
324
|
-
|
|
325
|
-
|
|
326
374
|
result = []
|
|
327
375
|
result << ['Date', 'Federal Holiday?', 'Comment']
|
|
328
376
|
result << nil
|
|
@@ -356,8 +404,6 @@ And we have similar methods for "holidays" or non-trading days on the NYSE:
|
|
|
356
404
|
Likewise, days on which the NYSE is closed can be gotten with:
|
|
357
405
|
|
|
358
406
|
#+begin_SRC ruby :results output
|
|
359
|
-
require './lib/fat_date'
|
|
360
|
-
|
|
361
407
|
puts Date.parse('2014-04-18').nyse_holiday?
|
|
362
408
|
#+end_SRC
|
|
363
409
|
|
|
@@ -366,8 +412,6 @@ true
|
|
|
366
412
|
#+end_example
|
|
367
413
|
|
|
368
414
|
#+begin_SRC ruby :results value
|
|
369
|
-
require './lib/fat_date'
|
|
370
|
-
|
|
371
415
|
date_comments = [
|
|
372
416
|
['2014-04-18', 'Good Friday'],
|
|
373
417
|
['2014-05-18', 'Weekend'],
|
|
@@ -400,8 +444,6 @@ wday, year, month)~ to return such dates. The first parameter can be
|
|
|
400
444
|
negative, which will count from the end of the month.
|
|
401
445
|
|
|
402
446
|
#+begin_src ruby
|
|
403
|
-
require './lib/fat_date'
|
|
404
|
-
|
|
405
447
|
results = []
|
|
406
448
|
results << ['n', 'Year', 'Month', 'nth Thursday']
|
|
407
449
|
results << nil
|
|
@@ -448,8 +490,6 @@ the reform happened after Easter in 1752.
|
|
|
448
490
|
- Date#easter? :: return whether the subject Date is Easter.
|
|
449
491
|
|
|
450
492
|
#+begin_src ruby
|
|
451
|
-
require './lib/fat_date'
|
|
452
|
-
|
|
453
493
|
yrs = [800, 1000, 1200, 1400, 1500, 1600, 1800, 2000]
|
|
454
494
|
result = []
|
|
455
495
|
result << ['Year', 'Easter Date']
|
|
@@ -473,7 +513,6 @@ the reform happened after Easter in 1752.
|
|
|
473
513
|
| 2000 | [2000-04-23 Sun] |
|
|
474
514
|
#+end_example
|
|
475
515
|
|
|
476
|
-
|
|
477
516
|
*** Date Specs
|
|
478
517
|
It is often desirable to get the first or last date of a specified time
|
|
479
518
|
period. For this ~FatDate~ provides the ~spec~ method that takes a string and
|
|
@@ -636,10 +675,9 @@ Some things to note with respect to ~Date.spec~:
|
|
|
636
675
|
6. 'fortnight' is a synonym for a biweek.
|
|
637
676
|
|
|
638
677
|
**** Examples
|
|
678
|
+
The following examples demonstrate all of the date specs available.
|
|
639
679
|
|
|
640
680
|
#+begin_src ruby results :value
|
|
641
|
-
require './lib/fat_date'
|
|
642
|
-
|
|
643
681
|
strs = ['today', '2024-07-04', '2024-05', '2024', '2024-333',
|
|
644
682
|
'08', '08-12', '2024-W36', '2024-36W', 'W36', '36W',
|
|
645
683
|
'2024-1H', '2024-2H', '1H', '2H',
|
|
@@ -665,7 +703,7 @@ Some things to note with respect to ~Date.spec~:
|
|
|
665
703
|
#+begin_example
|
|
666
704
|
| Spec | From | To |
|
|
667
705
|
|-----------------+------------------+------------------|
|
|
668
|
-
| 'today' | [2025-10-
|
|
706
|
+
| 'today' | [2025-10-24 Fri] | [2025-10-24 Fri] |
|
|
669
707
|
| '2024-07-04' | [2024-07-04 Thu] | [2024-07-04 Thu] |
|
|
670
708
|
| '2024-05' | [2024-05-01 Wed] | [2024-05-31 Fri] |
|
|
671
709
|
| '2024' | [2024-01-01 Mon] | [2024-12-31 Tue] |
|
|
@@ -711,9 +749,10 @@ Some things to note with respect to ~Date.spec~:
|
|
|
711
749
|
| '2025-E+50>=Su' | [2025-06-15 Sun] | [2025-06-15 Sun] |
|
|
712
750
|
#+end_example
|
|
713
751
|
|
|
752
|
+
|
|
714
753
|
* Contributing
|
|
715
754
|
|
|
716
|
-
1. Fork it ([[http://github.com/ddoherty03/
|
|
755
|
+
1. Fork it ([[http://github.com/ddoherty03/fat_date/fork]] )
|
|
717
756
|
2. Create your feature branch (~git checkout -b my-new-feature~)
|
|
718
757
|
3. Commit your changes (~git commit -am 'Add some feature'~)
|
|
719
758
|
4. Push to the branch (~git push origin my-new-feature~)
|
data/Rakefile
CHANGED
|
@@ -5,8 +5,22 @@ require "rspec/core/rake_task"
|
|
|
5
5
|
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
########################################################################
|
|
9
|
+
# Rubocop tasks
|
|
10
|
+
########################################################################
|
|
11
|
+
# Option A (recommended): Keep using Bundler and run rubocop via `bundle exec`.
|
|
12
|
+
# This wrapper task ensures the rubocop run uses the gems from your Gemfile,
|
|
13
|
+
# even when you invoke `rake rubocop` (no need to remember `bundle exec rake`).
|
|
14
|
+
#
|
|
15
|
+
# You can pass extra RuboCop CLI flags with the RUBOCOP_OPTS environment variable:
|
|
16
|
+
# RUBOCOP_OPTS="--format simple" rake rubocop
|
|
9
17
|
|
|
10
|
-
|
|
18
|
+
desc "Run rubocop under `bundle exec`"
|
|
19
|
+
task :rubocop do
|
|
20
|
+
opts = (ENV['RUBOCOP_OPTS'] || '').split
|
|
21
|
+
Bundler.with_unbundled_env do
|
|
22
|
+
sh 'bundle', 'exec', 'rubocop', *opts
|
|
23
|
+
end
|
|
24
|
+
end
|
|
11
25
|
|
|
12
|
-
task default
|
|
26
|
+
task :default => [:spec, :rubocop]
|
data/lib/fat_date/date.rb
CHANGED
|
@@ -2011,7 +2011,7 @@ module FatDate
|
|
|
2011
2011
|
#
|
|
2012
2012
|
# @param dat [String, Date, Time] the object to be converted to Date
|
|
2013
2013
|
# @return [Date, DateTime]
|
|
2014
|
-
def
|
|
2014
|
+
def ensure(dat)
|
|
2015
2015
|
if dat.is_a?(Date) || dat.is_a?(DateTime)
|
|
2016
2016
|
dat
|
|
2017
2017
|
elsif dat.is_a?(Time)
|
|
@@ -2030,22 +2030,19 @@ module FatDate
|
|
|
2030
2030
|
raise ArgumentError, "cannot convert class '#{dat.class}' to a Date or DateTime"
|
|
2031
2031
|
end
|
|
2032
2032
|
end
|
|
2033
|
+
|
|
2034
|
+
alias_method :ensure_date, :ensure
|
|
2033
2035
|
end
|
|
2034
2036
|
|
|
2037
|
+
# Extend the Date class methods with the FatDate::ClassMethods methods
|
|
2038
|
+
# when this module is included.
|
|
2035
2039
|
def self.included(base)
|
|
2036
2040
|
base.extend(ClassMethods)
|
|
2037
2041
|
end
|
|
2038
2042
|
end
|
|
2039
2043
|
end
|
|
2040
2044
|
|
|
2041
|
-
# Include the FatDate methods in Date
|
|
2042
|
-
# the FatDate::ClassMethods methods.
|
|
2045
|
+
# Include the FatDate methods in Date.
|
|
2043
2046
|
class Date
|
|
2044
2047
|
include FatDate::Date
|
|
2045
|
-
|
|
2046
|
-
def self.ensure(dat)
|
|
2047
|
-
ensure_date(dat)
|
|
2048
|
-
end
|
|
2049
|
-
# @!parse include FatDate::Date
|
|
2050
|
-
# @!parse extend FatDate::Date::ClassMethods
|
|
2051
2048
|
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
module FatDate
|
|
2
|
+
module DateTime
|
|
3
|
+
# Format as an ISO string of the form `YYYY-MM-DD`.
|
|
4
|
+
# @return [String]
|
|
5
|
+
def iso
|
|
6
|
+
strftime('%Y-%m-%dT%H:%M:%S.%3N%:%z')
|
|
7
|
+
end
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
# Include the FatDate methods in Date and extend the Date class methods with
|
|
12
|
+
# the FatDate::ClassMethods methods.
|
|
13
|
+
class DateTime
|
|
14
|
+
include FatDate::DateTime
|
|
15
|
+
end
|
data/lib/fat_date/version.rb
CHANGED
data/lib/fat_date.rb
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'active_support'
|
|
4
|
-
# require 'active_support/core_ext/object/blank'
|
|
5
|
-
# require 'active_support/core_ext/object/deep_dup'
|
|
6
4
|
require "active_support/isolated_execution_state"
|
|
7
5
|
require "active_support/core_ext/date"
|
|
8
6
|
require "active_support/core_ext/time"
|
|
@@ -14,5 +12,4 @@ require 'fat_core/string'
|
|
|
14
12
|
require_relative "fat_date/version"
|
|
15
13
|
require_relative "fat_date/patches"
|
|
16
14
|
require_relative "fat_date/date"
|
|
17
|
-
|
|
18
|
-
require 'debug'
|
|
15
|
+
require_relative "fat_date/datetime"
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: fat_date
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Daniel E. Doherty
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date:
|
|
10
|
+
date: 2025-12-04 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: activesupport
|
|
@@ -23,6 +23,20 @@ dependencies:
|
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '0'
|
|
26
|
+
- !ruby/object:Gem::Dependency
|
|
27
|
+
name: fat_core
|
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
|
29
|
+
requirements:
|
|
30
|
+
- - ">="
|
|
31
|
+
- !ruby/object:Gem::Version
|
|
32
|
+
version: '0'
|
|
33
|
+
type: :runtime
|
|
34
|
+
prerelease: false
|
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
+
requirements:
|
|
37
|
+
- - ">="
|
|
38
|
+
- !ruby/object:Gem::Version
|
|
39
|
+
version: '0'
|
|
26
40
|
description: |
|
|
27
41
|
FatDate provides useful extensions to the Date class including a way to
|
|
28
42
|
specify dates via a number of rich 'specs', strings that allow specifying
|
|
@@ -44,6 +58,7 @@ files:
|
|
|
44
58
|
- Rakefile
|
|
45
59
|
- lib/fat_date.rb
|
|
46
60
|
- lib/fat_date/date.rb
|
|
61
|
+
- lib/fat_date/datetime.rb
|
|
47
62
|
- lib/fat_date/patches.rb
|
|
48
63
|
- lib/fat_date/version.rb
|
|
49
64
|
- sig/fat_date.rbs
|
|
@@ -67,7 +82,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
67
82
|
- !ruby/object:Gem::Version
|
|
68
83
|
version: '0'
|
|
69
84
|
requirements: []
|
|
70
|
-
rubygems_version: 3.6.
|
|
85
|
+
rubygems_version: 3.6.3
|
|
71
86
|
specification_version: 4
|
|
72
87
|
summary: Useful extensions to the Date class.
|
|
73
88
|
test_files: []
|