fat_date 0.1.4 → 0.2.1
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/.yardopts +4 -0
- data/CHANGELOG.org +3 -0
- data/README.md +685 -0
- data/README.org +186 -175
- data/Rakefile +3 -0
- data/doc/Date.html +153 -0
- data/doc/DateTime.html +148 -0
- data/doc/FatDate/Date/ClassMethods.html +1930 -0
- data/doc/FatDate/Date.html +8319 -0
- data/doc/FatDate/DateTime.html +203 -0
- data/doc/FatDate.html +158 -0
- data/doc/Numeric.html +298 -0
- data/doc/_index.html +167 -0
- data/doc/class_list.html +54 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +490 -0
- data/doc/file.README.html +780 -0
- data/doc/file_list.html +59 -0
- data/doc/frames.html +22 -0
- data/doc/index.html +780 -0
- data/doc/js/app.js +395 -0
- data/doc/js/full_list.js +244 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +814 -0
- data/doc/top-level-namespace.html +112 -0
- data/lib/fat_date/date.rb +20 -2
- data/lib/fat_date/{datetime.rb → date_time.rb} +2 -0
- data/lib/fat_date/version.rb +1 -1
- data/lib/fat_date.rb +22 -4
- metadata +27 -4
data/README.org
CHANGED
|
@@ -1,81 +1,16 @@
|
|
|
1
1
|
#+TITLE: FatDate Guide
|
|
2
2
|
#+OPTIONS: toc:5
|
|
3
|
-
#+PROPERTY: header-args:ruby :
|
|
4
|
-
#+PROPERTY: header-args:
|
|
3
|
+
#+PROPERTY: header-args:ruby :results value :colnames no :hlines yes :exports both :dir "./"
|
|
4
|
+
#+PROPERTY: header-args:ruby+ :wrap example :session fat_date_session :eval yes
|
|
5
|
+
#+PROPERTY: header-args:ruby+ :prologue "$:.unshift('./lib') unless $:.first == './lib'; require 'fat_date'"
|
|
6
|
+
#+PROPERTY: header-args:sh :exports code :eval no
|
|
7
|
+
#+PROPERTY: header-args:bash :exports code :eval no
|
|
5
8
|
|
|
9
|
+
#+BEGIN_EXPORT markdown
|
|
10
|
+
[](https://github.com/ddoherty03/fat_date/actions/workflows/ruby.yml)
|
|
11
|
+
#+END_EXPORT
|
|
6
12
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
,#+BEGIN_COMMENT
|
|
10
|
-
|
|
11
|
-
* Setup for Code Blocks :noexport:
|
|
12
|
-
Run this block before all others to ensure that we are reading the libraries
|
|
13
|
-
from the source directory.
|
|
14
|
-
|
|
15
|
-
#+begin_src ruby :results output :export no
|
|
16
|
-
puts "Current directory: #{Dir.pwd}"
|
|
17
|
-
puts "Ruby LOADPATH:"
|
|
18
|
-
$LOAD_PATH.unshift(File.expand_path("lib", Dir.pwd)) unless $:[0].match?(%r{src/fat_date/lib})
|
|
19
|
-
$:[0..10].each { |d| puts d }
|
|
20
|
-
puts "..."
|
|
21
|
-
require 'fat_date'
|
|
22
|
-
#+end_src
|
|
23
|
-
|
|
24
|
-
#+RESULTS:
|
|
25
|
-
#+begin_example
|
|
26
|
-
Current directory: /home/ded/src/fat_date
|
|
27
|
-
Ruby LOADPATH:
|
|
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
|
|
30
|
-
/home/ded/.rbenv/rbenv.d/exec/gem-rehash
|
|
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
|
|
39
|
-
...
|
|
40
|
-
#+end_example
|
|
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]]
|
|
77
|
-
|
|
78
|
-
* FatDate
|
|
13
|
+
* Introduction
|
|
79
14
|
~fat_date~ collects core extensions for the Date class to make it more useful
|
|
80
15
|
in financial applications, including:
|
|
81
16
|
|
|
@@ -92,32 +27,32 @@ in financial applications, including:
|
|
|
92
27
|
|
|
93
28
|
* Version
|
|
94
29
|
|
|
95
|
-
#+begin_src ruby
|
|
96
|
-
|
|
30
|
+
#+begin_src ruby
|
|
31
|
+
FatDate::VERSION
|
|
97
32
|
#+end_src
|
|
98
33
|
|
|
34
|
+
#+RESULTS:
|
|
99
35
|
#+begin_example
|
|
100
|
-
0.1.
|
|
36
|
+
0.1.5
|
|
101
37
|
#+end_example
|
|
102
38
|
|
|
103
|
-
|
|
104
39
|
* Installation
|
|
105
40
|
|
|
106
41
|
Add this line to your application's Gemfile:
|
|
107
42
|
|
|
108
|
-
#+begin_SRC ruby
|
|
43
|
+
#+begin_SRC ruby :eval no
|
|
109
44
|
gem 'fat_date', :git => 'https://github.com/ddoherty03/fat_date.git'
|
|
110
45
|
#+end_SRC
|
|
111
46
|
|
|
112
47
|
And then execute:
|
|
113
48
|
|
|
114
|
-
#+begin_src
|
|
49
|
+
#+begin_src sh
|
|
115
50
|
$ bundle
|
|
116
51
|
#+end_src
|
|
117
52
|
|
|
118
53
|
Or install it yourself as:
|
|
119
54
|
|
|
120
|
-
#+begin_src
|
|
55
|
+
#+begin_src sh
|
|
121
56
|
$ gem install fat_date
|
|
122
57
|
#+end_src
|
|
123
58
|
|
|
@@ -146,23 +81,39 @@ method to a String. This is handy when you want to define a method that takes
|
|
|
146
81
|
a date argument but want the caller to be able to supply anything that can
|
|
147
82
|
reasonably be converted to a ~Date~:
|
|
148
83
|
|
|
149
|
-
#+begin_src ruby :results
|
|
150
|
-
# require 'fat_date'
|
|
84
|
+
#+begin_src ruby :results value raw
|
|
151
85
|
def tomorow_tomorrow(arg)
|
|
152
86
|
from = Date.ensure(arg) # => ArgumentError: cannot convert class 'Array' to a Date or DateTime
|
|
153
87
|
from + 2.days # => Mon, 03 Jun 2024, Wed, 16 Oct 2024 05:47:30 -0500, Sun, 03 Mar 2024
|
|
154
88
|
end # => :tomorow_tomorrow
|
|
155
89
|
|
|
156
|
-
|
|
157
|
-
puts tomorow_tomorrow(Time.now).to_s
|
|
158
|
-
# But it's only as good as Date.parse! If all it sees is 'March', it returns
|
|
159
|
-
# March 1 of the current year.
|
|
160
|
-
puts tomorow_tomorrow('Ides of March').to_s
|
|
90
|
+
tomorow_tomorrow('June 1').to_s
|
|
161
91
|
#+end_src
|
|
162
92
|
|
|
93
|
+
#+RESULTS:
|
|
163
94
|
#+begin_example
|
|
164
95
|
2025-06-03
|
|
165
|
-
|
|
96
|
+
#+end_example
|
|
97
|
+
|
|
98
|
+
If you give it a Time, it will return a ~DateTime~
|
|
99
|
+
#+begin_src ruby :results value raw
|
|
100
|
+
[Time.now, tomorow_tomorrow(Time.now)]
|
|
101
|
+
#+end_src
|
|
102
|
+
|
|
103
|
+
#+RESULTS:
|
|
104
|
+
#+begin_example
|
|
105
|
+
[2025-12-24 08:06:12.733499363 -0600, Fri, 26 Dec 2025 08:06:12 -0600]
|
|
106
|
+
#+end_example
|
|
107
|
+
|
|
108
|
+
But it's only as good as Date.parse! If all it sees is 'March', it returns
|
|
109
|
+
March 1 of the current year.
|
|
110
|
+
|
|
111
|
+
#+begin_src ruby :results value raw
|
|
112
|
+
tomorow_tomorrow('Ides of March').to_s
|
|
113
|
+
#+end_src
|
|
114
|
+
|
|
115
|
+
#+RESULTS:
|
|
116
|
+
#+begin_example
|
|
166
117
|
2025-03-03
|
|
167
118
|
#+end_example
|
|
168
119
|
|
|
@@ -170,28 +121,31 @@ reasonably be converted to a ~Date~:
|
|
|
170
121
|
~FatDate~ provides some concise methods for printing string versions of dates
|
|
171
122
|
that are often useful:
|
|
172
123
|
|
|
173
|
-
#+begin_SRC ruby :results
|
|
124
|
+
#+begin_SRC ruby :results value
|
|
174
125
|
d = Date.parse('1957-09-22')
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
126
|
+
methods = ['iso', 'num', 'tex_quote', 'eng', 'american', 'org']
|
|
127
|
+
tab = []
|
|
128
|
+
tab << ['Description', 'Result']
|
|
129
|
+
tab << nil
|
|
130
|
+
methods.each do |m|
|
|
131
|
+
tab << [m, d.send(m.to_sym)]
|
|
132
|
+
end
|
|
133
|
+
tab << ["org(active: true)", d.org(active: true)]
|
|
182
134
|
#+end_SRC
|
|
183
135
|
|
|
136
|
+
#+RESULTS:
|
|
184
137
|
#+begin_example
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
138
|
+
| Description | Result |
|
|
139
|
+
|-------------------+--------------------|
|
|
140
|
+
| iso | 1957-09-22 |
|
|
141
|
+
| num | 19570922 |
|
|
142
|
+
| tex_quote | 1957--09--22 |
|
|
143
|
+
| eng | September 22, 1957 |
|
|
144
|
+
| american | 9/22/1957 |
|
|
145
|
+
| org | [1957-09-22 Sun] |
|
|
146
|
+
| org(active: true) | <1957-09-22 Sun> |
|
|
192
147
|
#+end_example
|
|
193
148
|
|
|
194
|
-
|
|
195
149
|
Most of these are self-explanatory, but a couple are not. The
|
|
196
150
|
~Date.org(active: false)~ method formats a date as an Emacs org-mode
|
|
197
151
|
timestamp, by default an inactive timestamp that does not show up in the org
|
|
@@ -220,7 +174,7 @@ as "chunks", and they are the following:
|
|
|
220
174
|
~FatDate~ provides methods that query whether the date falls on the beginning
|
|
221
175
|
or end of each of these chunks:
|
|
222
176
|
|
|
223
|
-
#+begin_SRC ruby
|
|
177
|
+
#+begin_SRC ruby
|
|
224
178
|
tab = []
|
|
225
179
|
tab << ['Subject Date', 'Method', 'Result']
|
|
226
180
|
tab << nil
|
|
@@ -234,6 +188,7 @@ or end of each of these chunks:
|
|
|
234
188
|
tab
|
|
235
189
|
#+end_SRC
|
|
236
190
|
|
|
191
|
+
#+RESULTS:
|
|
237
192
|
#+begin_example
|
|
238
193
|
| Subject Date | Method | Result |
|
|
239
194
|
|--------------+-------------------------+--------|
|
|
@@ -272,6 +227,7 @@ or end of the calendar chunk, starting at the given date:
|
|
|
272
227
|
tab
|
|
273
228
|
#+end_SRC
|
|
274
229
|
|
|
230
|
+
#+RESULTS:
|
|
275
231
|
#+begin_example
|
|
276
232
|
| Subject Date | Method | Result |
|
|
277
233
|
|--------------+--------------------------+------------|
|
|
@@ -293,7 +249,6 @@ or end of the calendar chunk, starting at the given date:
|
|
|
293
249
|
| 2017-04-21 | d.end_of_week | 2017-04-23 |
|
|
294
250
|
#+end_example
|
|
295
251
|
|
|
296
|
-
|
|
297
252
|
You can query which numerical half, quarter, etc. that a given date falls in:
|
|
298
253
|
|
|
299
254
|
#+begin_SRC ruby
|
|
@@ -308,17 +263,18 @@ You can query which numerical half, quarter, etc. that a given date falls in:
|
|
|
308
263
|
tab
|
|
309
264
|
#+end_SRC
|
|
310
265
|
|
|
266
|
+
#+RESULTS:
|
|
311
267
|
#+begin_example
|
|
312
268
|
| Subject Date | Method | Result |
|
|
313
269
|
|--------------+-------------+------------------------|
|
|
314
|
-
| 2017-
|
|
315
|
-
| 2017-
|
|
316
|
-
| 2017-
|
|
317
|
-
| 2017-06-
|
|
318
|
-
| 2017-
|
|
319
|
-
| 2017-06-
|
|
320
|
-
| 2017-05
|
|
321
|
-
| 2017-07-
|
|
270
|
+
| 2017-05-14 | d.year | in year number 2017 |
|
|
271
|
+
| 2017-07-23 | d.half | in half number 2 |
|
|
272
|
+
| 2017-06-28 | d.quarter | in quarter number 2 |
|
|
273
|
+
| 2017-06-12 | d.bimonth | in bimonth number 3 |
|
|
274
|
+
| 2017-05-24 | d.month | in month number 5 |
|
|
275
|
+
| 2017-06-16 | d.semimonth | in semimonth number 12 |
|
|
276
|
+
| 2017-06-05 | d.biweek | in biweek number 12 |
|
|
277
|
+
| 2017-07-16 | d.week | in week number 28 |
|
|
322
278
|
#+end_example
|
|
323
279
|
|
|
324
280
|
*** Parsing American Dates
|
|
@@ -337,9 +293,13 @@ such strings.
|
|
|
337
293
|
end
|
|
338
294
|
#+end_SRC
|
|
339
295
|
|
|
296
|
+
#+RESULTS:
|
|
340
297
|
#+begin_example
|
|
298
|
+
=> false
|
|
341
299
|
Date.parse('9/22/1957') raises Date::Error (invalid date), but
|
|
342
300
|
Date.parse_american('9/22/1957') => 1957-09-22
|
|
301
|
+
=> nil
|
|
302
|
+
:org_babel_ruby_eoe
|
|
343
303
|
#+end_example
|
|
344
304
|
|
|
345
305
|
*** Holidays and Workdays
|
|
@@ -370,19 +330,52 @@ Methods concerning Federal holidays:
|
|
|
370
330
|
- Date#prior_until_fed_workday -- starting with this date, move back until
|
|
371
331
|
we hit a Federal workday
|
|
372
332
|
|
|
333
|
+
Whether a particular date is a federal holiday is complicated. Certain
|
|
334
|
+
holidays are statutory as set forth in [[https://www.govinfo.gov/content/pkg/USCODE-2024-title5/pdf/USCODE-2024-title5-partIII-subpartE-chap61-subchapI-sec6103.pdf][5 U.S.C. §6103]]. But if the holiday
|
|
335
|
+
falls on a Saturday, the prior Friday is observed; if on a Sunday, the
|
|
336
|
+
following Monday is observed. Inauguration Day after 1965 is observed by
|
|
337
|
+
employees in Washington, D.C., and surrounding areas, effectively shutting
|
|
338
|
+
down most federal agencies.
|
|
339
|
+
|
|
340
|
+
On top of that the days of Presidential funeral are federal holidays. On
|
|
341
|
+
top of that, each President can decree temporary holidays by Executive
|
|
342
|
+
Order, often to give employees Christmas Eve and the day after Christmas the
|
|
343
|
+
day off if they would not otherwise be off. The ~fat_date~ library attempts
|
|
344
|
+
to capture all of this, but the days of Presidential decrees are only good
|
|
345
|
+
for the last decade or so.
|
|
346
|
+
|
|
347
|
+
Here is a sampling:
|
|
348
|
+
|
|
373
349
|
#+begin_SRC ruby
|
|
374
350
|
result = []
|
|
375
351
|
result << ['Date', 'Federal Holiday?', 'Comment']
|
|
376
352
|
result << nil
|
|
353
|
+
result << ['2014-05-16', Date.parse('2014-05-16').fed_holiday?, 'Nuttin special']
|
|
377
354
|
result << ['2014-05-18', Date.parse('2014-05-18').fed_holiday?, 'A weekend']
|
|
378
|
-
result << ['2014-01-01', Date.parse('2014-
|
|
355
|
+
result << ['2014-01-01', Date.parse('2014-01-01').fed_holiday?, 'New Year']
|
|
356
|
+
result << ['1963-11-25', Date.parse('1963-11-25').fed_holiday?, 'JFK Funeral']
|
|
357
|
+
result << ['1973-01-25', Date.parse('1973-01-25').fed_holiday?, 'LBJ Funeral']
|
|
358
|
+
result << ['2003-12-25', Date.parse('2003-12-25').fed_holiday?, 'Christmas']
|
|
359
|
+
result << ['1961-01-20', Date.parse('1961-01-20').fed_holiday?, 'JFK Inauguration (before 1965)']
|
|
360
|
+
result << ['1969-01-20', Date.parse('1969-01-20').fed_holiday?, 'RMN Inauguration (after 1965)']
|
|
361
|
+
result << ['2012-12-24', Date.parse('2012-12-24').fed_holiday?, 'Christmas Eve Decreed by Obama']
|
|
362
|
+
result << ['2003-12-26', Date.parse('2003-12-26').fed_holiday?, 'Friday after Christmas']
|
|
379
363
|
#+end_SRC
|
|
380
364
|
|
|
365
|
+
#+RESULTS:
|
|
381
366
|
#+begin_example
|
|
382
|
-
| Date | Federal Holiday? | Comment
|
|
383
|
-
|
|
384
|
-
| 2014-05-
|
|
385
|
-
| 2014-
|
|
367
|
+
| Date | Federal Holiday? | Comment |
|
|
368
|
+
|------------+------------------+--------------------------------|
|
|
369
|
+
| 2014-05-16 | false | Nuttin special |
|
|
370
|
+
| 2014-05-18 | true | A weekend |
|
|
371
|
+
| 2014-01-01 | true | New Year |
|
|
372
|
+
| 1963-11-25 | true | JFK Funeral |
|
|
373
|
+
| 1973-01-25 | true | LBJ Funeral |
|
|
374
|
+
| 2003-12-25 | true | Christmas |
|
|
375
|
+
| 1961-01-20 | false | JFK Inauguration (before 1965) |
|
|
376
|
+
| 1969-01-20 | true | RMN Inauguration (after 1965) |
|
|
377
|
+
| 2012-12-24 | true | Christmas Eve Decreed by Obama |
|
|
378
|
+
| 2003-12-26 | true | Friday after Christmas |
|
|
386
379
|
#+end_example
|
|
387
380
|
|
|
388
381
|
**** NYSE
|
|
@@ -403,10 +396,11 @@ And we have similar methods for "holidays" or non-trading days on the NYSE:
|
|
|
403
396
|
|
|
404
397
|
Likewise, days on which the NYSE is closed can be gotten with:
|
|
405
398
|
|
|
406
|
-
#+begin_SRC ruby :results
|
|
407
|
-
|
|
399
|
+
#+begin_SRC ruby :results value raw
|
|
400
|
+
Date.parse('2014-04-18').nyse_holiday?
|
|
408
401
|
#+end_SRC
|
|
409
402
|
|
|
403
|
+
#+RESULTS:
|
|
410
404
|
#+begin_example
|
|
411
405
|
true
|
|
412
406
|
#+end_example
|
|
@@ -428,6 +422,7 @@ true
|
|
|
428
422
|
result
|
|
429
423
|
#+end_SRC
|
|
430
424
|
|
|
425
|
+
#+RESULTS:
|
|
431
426
|
#+begin_example
|
|
432
427
|
| Date | Federal Holiday? | NYSE Holiday? | Comment |
|
|
433
428
|
|------------------+------------------+---------------+-------------|
|
|
@@ -437,6 +432,7 @@ true
|
|
|
437
432
|
| [2014-01-01 Wed] | true | true | New Year |
|
|
438
433
|
#+end_example
|
|
439
434
|
|
|
435
|
+
|
|
440
436
|
*** Ordinal Weekdays in Month
|
|
441
437
|
It is often useful to find the 1st, 2nd, etc, Sunday, Monday, etc. in a given
|
|
442
438
|
month. ~FatDate~ provides the class method ~Date.nth_wday_in_year_month(nth,
|
|
@@ -458,6 +454,7 @@ negative, which will count from the end of the month.
|
|
|
458
454
|
results
|
|
459
455
|
#+end_src
|
|
460
456
|
|
|
457
|
+
#+RESULTS:
|
|
461
458
|
#+begin_example
|
|
462
459
|
| n | Year | Month | nth Thursday |
|
|
463
460
|
|----+------+-------+------------------|
|
|
@@ -500,6 +497,7 @@ the reform happened after Easter in 1752.
|
|
|
500
497
|
result
|
|
501
498
|
#+end_src
|
|
502
499
|
|
|
500
|
+
#+RESULTS:
|
|
503
501
|
#+begin_example
|
|
504
502
|
| Year | Easter Date |
|
|
505
503
|
|------+------------------|
|
|
@@ -636,13 +634,13 @@ modifier' to change the date to the first day-of-week adjacent to the date
|
|
|
636
634
|
that the spec resolves to. This is done by appending one of the following to
|
|
637
635
|
the spec:
|
|
638
636
|
|
|
639
|
-
- '<Su', '<Mo', ... '<Sa' ::
|
|
637
|
+
- '<Su', '<Mo', ... '<Sa' :: skip to the first Sunday, Monday, etc.,
|
|
640
638
|
/before/ the date the spec resolves to.
|
|
641
|
-
- '<=Su', '<=Mo', ... '<=Sa' ::
|
|
639
|
+
- '<=Su', '<=Mo', ... '<=Sa' :: skip to the first Sunday, Monday, etc., /on
|
|
642
640
|
or before/ the date the spec resolves to.
|
|
643
|
-
- '>Su', '>Mo', ... '>Sa' ::
|
|
641
|
+
- '>Su', '>Mo', ... '>Sa' :: skip to the first Sunday, Monday, etc.,
|
|
644
642
|
/after/ the date the spec resolves to.
|
|
645
|
-
- '>=Su', '>=Mo', ... '>=Sa' ::
|
|
643
|
+
- '>=Su', '>=Mo', ... '>=Sa' :: skip to the first Sunday, Monday, etc., /on
|
|
646
644
|
or after/ the date the spec resolves to.
|
|
647
645
|
|
|
648
646
|
For example, ~Date.spec('2024<=Tu', :to)~ resolves to the last Tuesday
|
|
@@ -683,12 +681,14 @@ The following examples demonstrate all of the date specs available.
|
|
|
683
681
|
'2024-1H', '2024-2H', '1H', '2H',
|
|
684
682
|
'1957-1Q', '1957-2Q', '1957-3Q', '1957-4Q',
|
|
685
683
|
'1Q', '2Q', '3Q', '4Q',
|
|
684
|
+
'2015-06-A', '2015-06-B', '06-A', '06-B', 'A', 'B',
|
|
686
685
|
'2021-09-I', '2021-09-II',
|
|
687
686
|
'2021-09-i', '2021-09-ii', '2021-09-iii', '2021-09-iv', '2021-09-v',
|
|
688
687
|
'10-i', '10-iii',
|
|
689
688
|
'2016-04-3Tu', '2016-11-4Th', '2016-11-2Th',
|
|
690
689
|
'05-3We', '06-3Wed', '3Su', '4Sa',
|
|
691
|
-
'1830-E', 'E', '2012-E+10', '2024-E+40',
|
|
690
|
+
'1830-E', 'E', '2012-E+10', '2024-E+40', '2026-E<Fri',
|
|
691
|
+
'yestermonth', 'lastmonth', 'yesterfortnight', 'thisfortnight', 'nextfortnight',
|
|
692
692
|
'2025-E+50>=Su'
|
|
693
693
|
]
|
|
694
694
|
tab = []
|
|
@@ -700,58 +700,69 @@ The following examples demonstrate all of the date specs available.
|
|
|
700
700
|
tab
|
|
701
701
|
#+end_src
|
|
702
702
|
|
|
703
|
+
#+RESULTS:
|
|
703
704
|
#+begin_example
|
|
704
|
-
| Spec
|
|
705
|
-
|
|
706
|
-
| 'today'
|
|
707
|
-
| '2024-07-04'
|
|
708
|
-
| '2024-05'
|
|
709
|
-
| '2024'
|
|
710
|
-
| '2024-333'
|
|
711
|
-
| '08'
|
|
712
|
-
| '08-12'
|
|
713
|
-
| '2024-W36'
|
|
714
|
-
| '2024-36W'
|
|
715
|
-
| 'W36'
|
|
716
|
-
| '36W'
|
|
717
|
-
| '2024-1H'
|
|
718
|
-
| '2024-2H'
|
|
719
|
-
| '1H'
|
|
720
|
-
| '2H'
|
|
721
|
-
| '1957-1Q'
|
|
722
|
-
| '1957-2Q'
|
|
723
|
-
| '1957-3Q'
|
|
724
|
-
| '1957-4Q'
|
|
725
|
-
| '1Q'
|
|
726
|
-
| '2Q'
|
|
727
|
-
| '3Q'
|
|
728
|
-
| '4Q'
|
|
729
|
-
| '
|
|
730
|
-
| '
|
|
731
|
-
| '
|
|
732
|
-
| '
|
|
733
|
-
| '
|
|
734
|
-
| '
|
|
735
|
-
| '2021-09-
|
|
736
|
-
| '
|
|
737
|
-
| '
|
|
738
|
-
| '
|
|
739
|
-
| '
|
|
740
|
-
| '
|
|
741
|
-
| '
|
|
742
|
-
| '
|
|
743
|
-
| '
|
|
744
|
-
| '
|
|
745
|
-
| '
|
|
746
|
-
| '
|
|
747
|
-
| '
|
|
748
|
-
| '
|
|
749
|
-
| '
|
|
705
|
+
| Spec | From | To |
|
|
706
|
+
|-------------------+------------------+------------------|
|
|
707
|
+
| 'today' | [2025-12-24 Wed] | [2025-12-24 Wed] |
|
|
708
|
+
| '2024-07-04' | [2024-07-04 Thu] | [2024-07-04 Thu] |
|
|
709
|
+
| '2024-05' | [2024-05-01 Wed] | [2024-05-31 Fri] |
|
|
710
|
+
| '2024' | [2024-01-01 Mon] | [2024-12-31 Tue] |
|
|
711
|
+
| '2024-333' | [2024-11-28 Thu] | [2024-11-28 Thu] |
|
|
712
|
+
| '08' | [2025-08-01 Fri] | [2025-08-31 Sun] |
|
|
713
|
+
| '08-12' | [2025-08-12 Tue] | [2025-08-12 Tue] |
|
|
714
|
+
| '2024-W36' | [2024-09-02 Mon] | [2024-09-08 Sun] |
|
|
715
|
+
| '2024-36W' | [2024-09-02 Mon] | [2024-09-08 Sun] |
|
|
716
|
+
| 'W36' | [2025-09-01 Mon] | [2025-09-07 Sun] |
|
|
717
|
+
| '36W' | [2025-09-01 Mon] | [2025-09-07 Sun] |
|
|
718
|
+
| '2024-1H' | [2024-01-01 Mon] | [2024-06-30 Sun] |
|
|
719
|
+
| '2024-2H' | [2024-07-01 Mon] | [2024-12-31 Tue] |
|
|
720
|
+
| '1H' | [2025-01-01 Wed] | [2025-06-30 Mon] |
|
|
721
|
+
| '2H' | [2025-07-01 Tue] | [2025-12-31 Wed] |
|
|
722
|
+
| '1957-1Q' | [1957-01-01 Tue] | [1957-03-31 Sun] |
|
|
723
|
+
| '1957-2Q' | [1957-04-01 Mon] | [1957-06-30 Sun] |
|
|
724
|
+
| '1957-3Q' | [1957-07-01 Mon] | [1957-09-30 Mon] |
|
|
725
|
+
| '1957-4Q' | [1957-10-01 Tue] | [1957-12-31 Tue] |
|
|
726
|
+
| '1Q' | [2025-01-01 Wed] | [2025-03-31 Mon] |
|
|
727
|
+
| '2Q' | [2025-04-01 Tue] | [2025-06-30 Mon] |
|
|
728
|
+
| '3Q' | [2025-07-01 Tue] | [2025-09-30 Tue] |
|
|
729
|
+
| '4Q' | [2025-10-01 Wed] | [2025-12-31 Wed] |
|
|
730
|
+
| '2015-06-A' | [2015-06-01 Mon] | [2015-06-15 Mon] |
|
|
731
|
+
| '2015-06-B' | [2015-06-16 Tue] | [2015-06-30 Tue] |
|
|
732
|
+
| '06-A' | [2025-06-01 Sun] | [2025-06-15 Sun] |
|
|
733
|
+
| '06-B' | [2025-06-16 Mon] | [2025-06-30 Mon] |
|
|
734
|
+
| 'A' | [2025-12-01 Mon] | [2025-12-15 Mon] |
|
|
735
|
+
| 'B' | [2025-12-16 Tue] | [2025-12-31 Wed] |
|
|
736
|
+
| '2021-09-I' | [2021-09-01 Wed] | [2021-09-05 Sun] |
|
|
737
|
+
| '2021-09-II' | [2021-09-06 Mon] | [2021-09-12 Sun] |
|
|
738
|
+
| '2021-09-i' | [2021-09-01 Wed] | [2021-09-05 Sun] |
|
|
739
|
+
| '2021-09-ii' | [2021-09-06 Mon] | [2021-09-12 Sun] |
|
|
740
|
+
| '2021-09-iii' | [2021-09-13 Mon] | [2021-09-19 Sun] |
|
|
741
|
+
| '2021-09-iv' | [2021-09-20 Mon] | [2021-09-26 Sun] |
|
|
742
|
+
| '2021-09-v' | [2021-09-27 Mon] | [2021-09-30 Thu] |
|
|
743
|
+
| '10-i' | [2025-10-01 Wed] | [2025-10-05 Sun] |
|
|
744
|
+
| '10-iii' | [2025-10-13 Mon] | [2025-10-19 Sun] |
|
|
745
|
+
| '2016-04-3Tu' | [2016-04-19 Tue] | [2016-04-19 Tue] |
|
|
746
|
+
| '2016-11-4Th' | [2016-11-24 Thu] | [2016-11-24 Thu] |
|
|
747
|
+
| '2016-11-2Th' | [2016-11-10 Thu] | [2016-11-10 Thu] |
|
|
748
|
+
| '05-3We' | [2025-05-21 Wed] | [2025-05-21 Wed] |
|
|
749
|
+
| '06-3Wed' | [2025-06-18 Wed] | [2025-06-18 Wed] |
|
|
750
|
+
| '3Su' | [2025-12-21 Sun] | [2025-12-21 Sun] |
|
|
751
|
+
| '4Sa' | [2025-12-27 Sat] | [2025-12-27 Sat] |
|
|
752
|
+
| '1830-E' | [1830-04-11 Sun] | [1830-04-11 Sun] |
|
|
753
|
+
| 'E' | [2025-04-20 Sun] | [2025-04-20 Sun] |
|
|
754
|
+
| '2012-E+10' | [2012-04-18 Wed] | [2012-04-18 Wed] |
|
|
755
|
+
| '2024-E+40' | [2024-05-10 Fri] | [2024-05-10 Fri] |
|
|
756
|
+
| '2026-E<Fri' | [2026-04-03 Fri] | [2026-04-03 Fri] |
|
|
757
|
+
| 'yestermonth' | [2025-11-01 Sat] | [2025-11-30 Sun] |
|
|
758
|
+
| 'lastmonth' | [2025-11-01 Sat] | [2025-11-30 Sun] |
|
|
759
|
+
| 'yesterfortnight' | [2025-12-08 Mon] | [2025-12-21 Sun] |
|
|
760
|
+
| 'thisfortnight' | [2025-12-22 Mon] | [2026-01-04 Sun] |
|
|
761
|
+
| 'nextfortnight' | [2026-01-05 Mon] | [2026-01-18 Sun] |
|
|
762
|
+
| '2025-E+50>=Su' | [2025-06-15 Sun] | [2025-06-15 Sun] |
|
|
750
763
|
#+end_example
|
|
751
764
|
|
|
752
|
-
|
|
753
765
|
* Contributing
|
|
754
|
-
|
|
755
766
|
1. Fork it ([[http://github.com/ddoherty03/fat_date/fork]] )
|
|
756
767
|
2. Create your feature branch (~git checkout -b my-new-feature~)
|
|
757
768
|
3. Commit your changes (~git commit -am 'Add some feature'~)
|
data/Rakefile
CHANGED
|
@@ -5,6 +5,9 @@ require "rspec/core/rake_task"
|
|
|
5
5
|
|
|
6
6
|
RSpec::Core::RakeTask.new(:spec)
|
|
7
7
|
|
|
8
|
+
require 'gem_docs'
|
|
9
|
+
GemDocs.install
|
|
10
|
+
|
|
8
11
|
########################################################################
|
|
9
12
|
# Rubocop tasks
|
|
10
13
|
########################################################################
|