anniversary 0.0.2 → 1.0.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.
data/.rvmrc ADDED
@@ -0,0 +1,2 @@
1
+ rvm_gemset_create_on_use_flag=1
2
+ rvm 1.8.7@anniversary
@@ -0,0 +1,118 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Module: Anniversary</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Module</strong></td>
53
+ <td class="class-name-in-header">Anniversary</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/anniversary/version_rb.html">
59
+ lib/anniversary/version.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ </table>
66
+ </div>
67
+ <!-- banner header -->
68
+
69
+ <div id="bodyContent">
70
+
71
+
72
+
73
+ <div id="contextContent">
74
+
75
+
76
+
77
+ </div>
78
+
79
+
80
+ </div>
81
+
82
+
83
+ <!-- if includes -->
84
+
85
+ <div id="section">
86
+
87
+
88
+ <div id="constants-list">
89
+ <h3 class="section-bar">Constants</h3>
90
+
91
+ <div class="name-list">
92
+ <table summary="Constants">
93
+ <tr class="top-aligned-row context-row">
94
+ <td class="context-item-name">VERSION</td>
95
+ <td>=</td>
96
+ <td class="context-item-value">&quot;0.0.2&quot;</td>
97
+ </tr>
98
+ </table>
99
+ </div>
100
+ </div>
101
+
102
+
103
+
104
+
105
+
106
+
107
+ <!-- if method_list -->
108
+
109
+
110
+ </div>
111
+
112
+
113
+ <div id="validator-badges">
114
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
115
+ </div>
116
+
117
+ </body>
118
+ </html>
@@ -0,0 +1,250 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Date</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href=".././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Date</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../files/lib/anniversary/date_additions_rb.html">
59
+ lib/anniversary/date_additions.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ Object
69
+ </td>
70
+ </tr>
71
+ </table>
72
+ </div>
73
+ <!-- banner header -->
74
+
75
+ <div id="bodyContent">
76
+
77
+
78
+
79
+ <div id="contextContent">
80
+
81
+
82
+
83
+ </div>
84
+
85
+ <div id="method-list">
86
+ <h3 class="section-bar">Methods</h3>
87
+
88
+ <div class="name-list">
89
+ <a href="#M000003">civil_with_missing_day_correction</a>&nbsp;&nbsp;
90
+ <a href="#M000002">in_year_and_month_with_correction</a>&nbsp;&nbsp;
91
+ <a href="#M000001">in_year_with_correction</a>&nbsp;&nbsp;
92
+ <a href="#M000004">years_months_days_since</a>&nbsp;&nbsp;
93
+ <a href="#M000005">years_months_days_until</a>&nbsp;&nbsp;
94
+ </div>
95
+ </div>
96
+
97
+ </div>
98
+
99
+
100
+ <!-- if includes -->
101
+
102
+ <div id="section">
103
+
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+ <!-- if method_list -->
112
+ <div id="methods">
113
+ <h3 class="section-bar">Public Class methods</h3>
114
+
115
+ <div id="method-M000003" class="method-detail">
116
+ <a name="M000003"></a>
117
+
118
+ <div class="method-heading">
119
+ <a href="Date.src/M000003.html" target="Code" class="method-signature"
120
+ onclick="popupCode('Date.src/M000003.html');return false;">
121
+ <span class="method-name">civil_with_missing_day_correction</span><span class="method-args">(year, month, day)</span>
122
+ </a>
123
+ </div>
124
+
125
+ <div class="method-description">
126
+ <p>
127
+ Return a date with a given year, month and day. If the date would be
128
+ invalid because that day does not exist in that month in that year, then
129
+ return an equivalent date, &#8216;reflected&#8217; around the end of the
130
+ month. For example, <a
131
+ href="Date.html#M000003">Date.civil_with_missing_day_correction</a>(2001,
132
+ 2, 29) would return Date.civil(2001, 3, 1), and <a
133
+ href="Date.html#M000003">Date.civil_with_missing_day_correction</a>(2011,
134
+ 2, 31) would return Date.civil(2011, 3, 2)
135
+ </p>
136
+ </div>
137
+ </div>
138
+
139
+ <h3 class="section-bar">Public Instance methods</h3>
140
+
141
+ <div id="method-M000002" class="method-detail">
142
+ <a name="M000002"></a>
143
+
144
+ <div class="method-heading">
145
+ <span class="method-name">in_year_and_month_with_correction</span><span class="method-args">(yr,mth=month)</span>
146
+ </div>
147
+
148
+ <div class="method-description">
149
+ <p>
150
+ Alias for <a href="Date.html#M000001">in_year_with_correction</a>
151
+ </p>
152
+ </div>
153
+ </div>
154
+
155
+ <div id="method-M000001" class="method-detail">
156
+ <a name="M000001"></a>
157
+
158
+ <div class="method-heading">
159
+ <a href="Date.src/M000001.html" target="Code" class="method-signature"
160
+ onclick="popupCode('Date.src/M000001.html');return false;">
161
+ <span class="method-name">in_year_with_correction</span><span class="method-args">(yr,mth=month)</span>
162
+ </a>
163
+ </div>
164
+
165
+ <div class="method-description">
166
+ <p>
167
+ Return the equivalent date in a different year and optionally month. If the
168
+ result of just changing the year and or month results in an invalid date
169
+ e.g. September 31 in any year, or February 29 in a non-leap year, then
170
+ return a valid date in the next month, see <a
171
+ href="Date.html#M000003">Date.civil_with_missing_day_correction</a>
172
+ </p>
173
+ </div>
174
+ </div>
175
+
176
+ <div id="method-M000004" class="method-detail">
177
+ <a name="M000004"></a>
178
+
179
+ <div class="method-heading">
180
+ <a href="Date.src/M000004.html" target="Code" class="method-signature"
181
+ onclick="popupCode('Date.src/M000004.html');return false;">
182
+ <span class="method-name">years_months_days_since(initial_date)<br />
183
+ </span>
184
+ </a>
185
+ </div>
186
+
187
+ <div class="method-description">
188
+ <p>
189
+ return a 3 element array comprising the number of years, months and days
190
+ which have occurred between the argument initial_date and the receiver
191
+ </p>
192
+ <p>
193
+ The return values are
194
+ </p>
195
+ <pre>
196
+ 0. years - the number of anniversary dates which have occurred
197
+ 1. months - the number of 'monthiversary' dates which have occurred since the last anniversary date
198
+ 2. days - the number of days since the last monthiversary
199
+ </pre>
200
+ <p>
201
+ If the receiver is before the argument then years, months and days will be
202
+ 0 or negative values.
203
+ </p>
204
+ </div>
205
+ </div>
206
+
207
+ <div id="method-M000005" class="method-detail">
208
+ <a name="M000005"></a>
209
+
210
+ <div class="method-heading">
211
+ <a href="Date.src/M000005.html" target="Code" class="method-signature"
212
+ onclick="popupCode('Date.src/M000005.html');return false;">
213
+ <span class="method-name">years_months_days_until(end_date)<br />
214
+ </span>
215
+ </a>
216
+ </div>
217
+
218
+ <div class="method-description">
219
+ <p>
220
+ return a 3 element array comprising the number of years, months and days
221
+ which will occur between the argument end_date and the receiver
222
+ </p>
223
+ <p>
224
+ The return values are
225
+ </p>
226
+ <pre>
227
+ 0. years - the number of anniversary dates which will occur
228
+ 1. months - the number of 'monthiversary' dates which will occur after the last anniversary date
229
+ 2. days - the number of days after the last monthiversary
230
+ </pre>
231
+ <p>
232
+ If the receiver is after the argument then years, months and days will be 0
233
+ or negative values.
234
+ </p>
235
+ </div>
236
+ </div>
237
+
238
+
239
+ </div>
240
+
241
+
242
+ </div>
243
+
244
+
245
+ <div id="validator-badges">
246
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
247
+ </div>
248
+
249
+ </body>
250
+ </html>
@@ -0,0 +1,18 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>in_year_with_correction (Date)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/anniversary/date_additions.rb, line 8</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">in_year_with_correction</span>(<span class="ruby-identifier">yr</span>,<span class="ruby-identifier">mth</span>=<span class="ruby-identifier">month</span>)
15
+ <span class="ruby-constant">Date</span>.<span class="ruby-identifier">civil_with_missing_day_correction</span>(<span class="ruby-identifier">yr</span>, <span class="ruby-identifier">mth</span>, <span class="ruby-identifier">day</span>)
16
+ <span class="ruby-keyword kw">end</span></pre>
17
+ </body>
18
+ </html>
@@ -0,0 +1,27 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>civil_with_missing_day_correction (Date)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/anniversary/date_additions.rb, line 17</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">civil_with_missing_day_correction</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>)
15
+ <span class="ruby-identifier">days_in_month</span> = [
16
+ <span class="ruby-comment cmt"># J F M A M J J A S O N D</span>
17
+ <span class="ruby-value">0</span>, <span class="ruby-value">31</span>, <span class="ruby-value">28</span>, <span class="ruby-value">31</span>, <span class="ruby-value">30</span>, <span class="ruby-value">31</span>, <span class="ruby-value">30</span>, <span class="ruby-value">31</span>, <span class="ruby-value">31</span>, <span class="ruby-value">30</span>, <span class="ruby-value">31</span>, <span class="ruby-value">30</span>, <span class="ruby-value">31</span>
18
+ ][<span class="ruby-identifier">month</span>]
19
+ <span class="ruby-identifier">days_in_month</span> = <span class="ruby-value">29</span> <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">month</span> <span class="ruby-operator">==</span> <span class="ruby-value">2</span>) <span class="ruby-operator">&amp;&amp;</span> ((<span class="ruby-identifier">year</span> <span class="ruby-operator">%</span> <span class="ruby-value">4</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>) <span class="ruby-operator">&amp;&amp;</span> ((<span class="ruby-identifier">year</span> <span class="ruby-operator">%</span> <span class="ruby-value">400</span> <span class="ruby-operator">==</span> <span class="ruby-value">0</span>) <span class="ruby-operator">||</span> (<span class="ruby-identifier">year</span> <span class="ruby-operator">%</span> <span class="ruby-value">100</span> <span class="ruby-operator">!=</span> <span class="ruby-value">0</span>)))
20
+ <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">days_in_month</span> <span class="ruby-operator">&lt;</span> <span class="ruby-identifier">day</span>)
21
+ <span class="ruby-identifier">month</span> <span class="ruby-operator">+=</span> <span class="ruby-value">1</span>
22
+ <span class="ruby-identifier">day</span> = <span class="ruby-identifier">day</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">days_in_month</span>
23
+ <span class="ruby-keyword kw">end</span>
24
+ <span class="ruby-identifier">civil</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-identifier">day</span>)
25
+ <span class="ruby-keyword kw">end</span></pre>
26
+ </body>
27
+ </html>
@@ -0,0 +1,48 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html>
7
+ <head>
8
+ <title>years_months_days_since (Date)</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
11
+ </head>
12
+ <body class="standalone-code">
13
+ <pre><span class="ruby-comment cmt"># File lib/anniversary/date_additions.rb, line 42</span>
14
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">years_months_days_since</span>(<span class="ruby-identifier">initial_date</span>, <span class="ruby-identifier">debug</span> = <span class="ruby-keyword kw">false</span>)
15
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">initial_date</span> <span class="ruby-operator">&lt;</span> <span class="ruby-keyword kw">self</span>
16
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;#{self}.years_months_days_since(#{initial_date})&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">debug</span>
17
+ <span class="ruby-identifier">anniversary_this_year</span> = <span class="ruby-identifier">initial_date</span>.<span class="ruby-identifier">in_year_with_correction</span>(<span class="ruby-identifier">year</span>)
18
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;anniversary_this_year is #{anniversary_this_year}&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">debug</span>
19
+ <span class="ruby-identifier">years</span> = <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">anniversary_this_year</span> <span class="ruby-operator">&lt;=</span> <span class="ruby-keyword kw">self</span>
20
+ <span class="ruby-identifier">year</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">initial_date</span>.<span class="ruby-identifier">year</span>
21
+ <span class="ruby-keyword kw">else</span>
22
+ <span class="ruby-identifier">year</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">initial_date</span>.<span class="ruby-identifier">year</span> <span class="ruby-operator">-</span> <span class="ruby-value">1</span>
23
+ <span class="ruby-keyword kw">end</span>
24
+ <span class="ruby-identifier">last_monthiversary</span> = <span class="ruby-identifier">monthiversary_this_month</span> = <span class="ruby-identifier">initial_date</span>.<span class="ruby-identifier">in_year_and_month_with_correction</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>)
25
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;monthiversary_this_month is #{monthiversary_this_month}&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">debug</span>
26
+ <span class="ruby-keyword kw">if</span> (<span class="ruby-identifier">monthiversary_this_month</span> <span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>)
27
+ <span class="ruby-identifier">last_month</span> = <span class="ruby-identifier">initial_date</span>.<span class="ruby-identifier">civil</span>(<span class="ruby-identifier">year</span>, <span class="ruby-identifier">month</span>, <span class="ruby-value">1</span>) <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-value">1</span>
28
+ <span class="ruby-identifier">last_monthiversary</span> = <span class="ruby-identifier">initial_date</span>.<span class="ruby-identifier">in_year_and_month_with_correction</span>(<span class="ruby-identifier">last_month</span>.<span class="ruby-identifier">year</span>, <span class="ruby-identifier">last_month</span>.<span class="ruby-identifier">month</span>)
29
+ <span class="ruby-keyword kw">end</span>
30
+ <span class="ruby-identifier">puts</span> <span class="ruby-node">&quot;last_monthiversary is #{last_monthiversary}&quot;</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">debug</span>
31
+
32
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">last_monthiversary</span> <span class="ruby-operator">&gt;</span> <span class="ruby-identifier">initial_date</span>
33
+ <span class="ruby-identifier">months</span> = (<span class="ruby-identifier">last_monthiversary</span>.<span class="ruby-identifier">month</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">anniversary_this_year</span>.<span class="ruby-identifier">month</span>)
34
+ <span class="ruby-identifier">months</span> <span class="ruby-operator">+=</span> <span class="ruby-value">12</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">months</span> <span class="ruby-operator">&lt;</span> <span class="ruby-value">0</span>
35
+ <span class="ruby-keyword kw">else</span>
36
+ <span class="ruby-identifier">months</span> = <span class="ruby-value">0</span>
37
+ <span class="ruby-keyword kw">end</span>
38
+ <span class="ruby-identifier">days</span> = (<span class="ruby-keyword kw">self</span> <span class="ruby-operator">-</span> <span class="ruby-identifier">last_monthiversary</span>).<span class="ruby-identifier">to_i</span>
39
+ <span class="ruby-keyword kw">elsif</span> <span class="ruby-identifier">initial_date</span> <span class="ruby-operator">&gt;</span> <span class="ruby-keyword kw">self</span>
40
+ <span class="ruby-identifier">initial_date</span>.<span class="ruby-identifier">years_months_days_since</span>(<span class="ruby-keyword kw">self</span>, <span class="ruby-identifier">debug</span>).<span class="ruby-identifier">map</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-operator">-</span><span class="ruby-identifier">v</span>}
41
+ <span class="ruby-keyword kw">else</span>
42
+ <span class="ruby-identifier">years</span>, <span class="ruby-identifier">months</span>, <span class="ruby-identifier">days</span> = <span class="ruby-value">0</span>, <span class="ruby-value">0</span>, <span class="ruby-value">0</span>
43
+ <span class="ruby-keyword kw">end</span>
44
+
45
+ [<span class="ruby-identifier">years</span>, <span class="ruby-identifier">months</span>, <span class="ruby-identifier">days</span>]
46
+ <span class="ruby-keyword kw">end</span></pre>
47
+ </body>
48
+ </html>