fat_date 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.
@@ -0,0 +1,112 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>
7
+ Top Level Namespace
8
+
9
+ &mdash; Documentation by YARD 0.9.38
10
+
11
+ </title>
12
+
13
+ <link rel="stylesheet" href="css/style.css" type="text/css" />
14
+
15
+ <link rel="stylesheet" href="css/common.css" type="text/css" />
16
+
17
+ <script type="text/javascript">
18
+ pathId = "";
19
+ relpath = '';
20
+ </script>
21
+
22
+
23
+ <script type="text/javascript" charset="utf-8" src="js/jquery.js"></script>
24
+
25
+ <script type="text/javascript" charset="utf-8" src="js/app.js"></script>
26
+
27
+
28
+ </head>
29
+ <body>
30
+ <div class="nav_wrap">
31
+ <iframe id="nav" src="class_list.html?1"></iframe>
32
+ <div id="resizer"></div>
33
+ </div>
34
+
35
+ <div id="main" tabindex="-1">
36
+ <div id="header">
37
+ <div id="menu">
38
+
39
+ <a href="_index.html">Index</a> &raquo;
40
+
41
+
42
+ <span class="title">Top Level Namespace</span>
43
+
44
+ </div>
45
+
46
+ <div id="search">
47
+
48
+ <a class="full_list_link" id="class_list_link"
49
+ href="class_list.html">
50
+
51
+ <svg width="24" height="24">
52
+ <rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
53
+ <rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
54
+ <rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
55
+ </svg>
56
+ </a>
57
+
58
+ </div>
59
+ <div class="clear"></div>
60
+ </div>
61
+
62
+ <div id="content"><h1>Top Level Namespace
63
+
64
+
65
+
66
+ </h1>
67
+ <div class="box_info">
68
+
69
+
70
+
71
+
72
+
73
+
74
+
75
+
76
+
77
+
78
+
79
+ </div>
80
+
81
+ <h2>Defined Under Namespace</h2>
82
+ <p class="children">
83
+
84
+
85
+ <strong class="modules">Modules:</strong> <span class='object_link'><a href="FatDate.html" title="FatDate (module)">FatDate</a></span>
86
+
87
+
88
+
89
+ <strong class="classes">Classes:</strong> <span class='object_link'><a href="Date.html" title="Date (class)">Date</a></span>, <span class='object_link'><a href="DateTime.html" title="DateTime (class)">DateTime</a></span>, <span class='object_link'><a href="Numeric.html" title="Numeric (class)">Numeric</a></span>
90
+
91
+
92
+ </p>
93
+
94
+
95
+
96
+
97
+
98
+
99
+
100
+
101
+
102
+ </div>
103
+
104
+ <div id="footer">
105
+ Generated on Wed Dec 24 05:26:32 2025 by
106
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
107
+ 0.9.38 (ruby-3.4.1).
108
+ </div>
109
+
110
+ </div>
111
+ </body>
112
+ </html>
data/lib/fat_date/date.rb CHANGED
@@ -925,7 +925,7 @@ module FatDate
925
925
  end
926
926
 
927
927
  # Holidays decreed by Presidential proclamation
928
- FED_DECREED_HOLIDAYS =
928
+ FED_DECREED_HOLIDAYS =
929
929
  [
930
930
  # Obama decree extra day before Christmas See
931
931
  # http://www.whitehouse.gov/the-press-office/2012/12/21
@@ -936,6 +936,9 @@ module FatDate
936
936
  ::Date.parse('2020-12-24'),
937
937
  # Biden
938
938
  ::Date.parse('2024-12-24'),
939
+ # Trump
940
+ ::Date.parse('2025-12-24'),
941
+ ::Date.parse('2025-12-26'),
939
942
  ]
940
943
 
941
944
  # Presidential funeral since JFK
@@ -1318,6 +1321,21 @@ module FatDate
1318
1321
  when 5
1319
1322
  # Memorial Day (Last Monday in May)
1320
1323
  year <= 1970 ? (month == 5 && day == 30) : nth_wday_in_month?(-1, 1, 5)
1324
+ when 6
1325
+ # Juneteenth, starting 2022. On June 19, but moved to prior Friday if
1326
+ # it falls on Saturday and moved to Monday if it fall on Sunday.
1327
+ if year < 2022
1328
+ false
1329
+ else
1330
+ jun19 = Date.new(year, 6, 19)
1331
+ if jun19.saturday?
1332
+ day == 18
1333
+ elsif jun19.sunday?
1334
+ day == 20
1335
+ else
1336
+ day == 19
1337
+ end
1338
+ end
1321
1339
  when 9
1322
1340
  # Labor Day (First Monday in Sep)
1323
1341
  nth_wday_in_month?(1, 1, 9)
@@ -2011,7 +2029,7 @@ module FatDate
2011
2029
  #
2012
2030
  # @param dat [String, Date, Time] the object to be converted to Date
2013
2031
  # @return [Date, DateTime]
2014
- def ensure_date(dat)
2032
+ def ensure(dat)
2015
2033
  if dat.is_a?(Date) || dat.is_a?(DateTime)
2016
2034
  dat
2017
2035
  elsif dat.is_a?(Time)
@@ -2030,22 +2048,19 @@ module FatDate
2030
2048
  raise ArgumentError, "cannot convert class '#{dat.class}' to a Date or DateTime"
2031
2049
  end
2032
2050
  end
2051
+
2052
+ alias_method :ensure_date, :ensure
2033
2053
  end
2034
2054
 
2055
+ # Extend the Date class methods with the FatDate::ClassMethods methods
2056
+ # when this module is included.
2035
2057
  def self.included(base)
2036
2058
  base.extend(ClassMethods)
2037
2059
  end
2038
2060
  end
2039
2061
  end
2040
2062
 
2041
- # Include the FatDate methods in Date and extend the Date class methods with
2042
- # the FatDate::ClassMethods methods.
2063
+ # Include the FatDate methods in Date.
2043
2064
  class Date
2044
2065
  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
2066
  end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module FatDate
4
+ module DateTime
5
+ # Format as an ISO string of the form `YYYY-MM-DD`.
6
+ # @return [String]
7
+ def iso
8
+ strftime('%Y-%m-%dT%H:%M:%S.%3N%:%z')
9
+ end
10
+ end
11
+ end
12
+
13
+ # Include the FatDate methods in Date and extend the Date class methods with
14
+ # the FatDate::ClassMethods methods.
15
+ class DateTime
16
+ include FatDate::DateTime
17
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module FatDate
4
- VERSION = "0.1.0"
4
+ VERSION = "0.2.0"
5
5
  end
data/lib/fat_date.rb CHANGED
@@ -1,8 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'date'
3
4
  require 'active_support'
4
- # require 'active_support/core_ext/object/blank'
5
- # require 'active_support/core_ext/object/deep_dup'
6
5
  require "active_support/isolated_execution_state"
7
6
  require "active_support/core_ext/date"
8
7
  require "active_support/core_ext/time"
@@ -11,8 +10,24 @@ require "active_support/core_ext/integer/time"
11
10
 
12
11
  require 'fat_core/string'
13
12
 
14
- require_relative "fat_date/version"
15
- require_relative "fat_date/patches"
16
- require_relative "fat_date/date"
17
-
18
- require 'debug'
13
+ # Gem Overview (extracted from README.org by gem_docs)
14
+ #
15
+ # * Introduction
16
+ # ~fat_date~ collects core extensions for the Date class to make it more useful
17
+ # in financial applications, including:
18
+ #
19
+ # - determining when a =Date= is a federal or NYSE holiday with Presidential
20
+ # decrees included,
21
+ # - determining when a =Date= is part of a larger calendar-related "chunk," such
22
+ # as a year, half, quarter, bimonth, month, semimonth, or week,
23
+ # - calculating Easter for a =Date's= year, a date on which some "movable
24
+ # feasts" depend, and
25
+ # - parsing so-called "specs" that allow the beginning or ending =Date= of a
26
+ # larger period of time to be returned, a facility put to good use in the
27
+ # [[https://github.com/ddoherty03/fat_period][FatPeriod]] gem.
28
+ module FatDate
29
+ require_relative "fat_date/version"
30
+ require_relative "fat_date/patches"
31
+ require_relative "fat_date/date"
32
+ require_relative "fat_date/date_time"
33
+ end
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.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel E. Doherty
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 1980-01-02 00:00:00.000000000 Z
10
+ date: 2026-06-30 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
@@ -38,12 +52,36 @@ files:
38
52
  - ".rspec"
39
53
  - ".rubocop.yml"
40
54
  - ".ruby-version"
55
+ - ".yardopts"
41
56
  - CHANGELOG.org
42
57
  - LICENSE.txt
58
+ - README.md
43
59
  - README.org
44
60
  - Rakefile
61
+ - doc/Date.html
62
+ - doc/DateTime.html
63
+ - doc/FatDate.html
64
+ - doc/FatDate/Date.html
65
+ - doc/FatDate/Date/ClassMethods.html
66
+ - doc/FatDate/DateTime.html
67
+ - doc/Numeric.html
68
+ - doc/_index.html
69
+ - doc/class_list.html
70
+ - doc/css/common.css
71
+ - doc/css/full_list.css
72
+ - doc/css/style.css
73
+ - doc/file.README.html
74
+ - doc/file_list.html
75
+ - doc/frames.html
76
+ - doc/index.html
77
+ - doc/js/app.js
78
+ - doc/js/full_list.js
79
+ - doc/js/jquery.js
80
+ - doc/method_list.html
81
+ - doc/top-level-namespace.html
45
82
  - lib/fat_date.rb
46
83
  - lib/fat_date/date.rb
84
+ - lib/fat_date/date_time.rb
47
85
  - lib/fat_date/patches.rb
48
86
  - lib/fat_date/version.rb
49
87
  - sig/fat_date.rbs
@@ -67,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
67
105
  - !ruby/object:Gem::Version
68
106
  version: '0'
69
107
  requirements: []
70
- rubygems_version: 3.6.7
108
+ rubygems_version: 3.6.2
71
109
  specification_version: 4
72
110
  summary: Useful extensions to the Date class.
73
111
  test_files: []