expanded_date 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,50 @@
1
+ require 'date'
2
+
3
+ class Date
4
+ def prev_month
5
+ m = month - 1
6
+ y = year
7
+ if m == 0
8
+ m = 12
9
+ y = y - 1
10
+ end
11
+ d = day
12
+ self::class.civil(y,m,d)
13
+ end
14
+
15
+ def next_month
16
+ m = month + 1
17
+ y = year
18
+ if m == 13
19
+ m = 1
20
+ y = y + 1
21
+ end
22
+ d = day
23
+ self::class.civil(y,m,d)
24
+ end
25
+
26
+ def end_of_month
27
+ d = next_month
28
+ self::class.civil(d.year, d.month, 1)-1
29
+ end
30
+
31
+ def beginning_of_month
32
+ self::class.civil(self.year, self.month, 1)
33
+ end
34
+
35
+ def end_of_next_month
36
+ self.beginning_of_month.next_month.end_of_month
37
+ end
38
+
39
+ def end_of_prev_month
40
+ self.beginning_of_month-1
41
+ end
42
+
43
+ def beginning_of_next_month
44
+ self.beginning_of_month.next_month
45
+ end
46
+
47
+ def beginning_of_prev_month
48
+ self.beginning_of_month.prev_month
49
+ end
50
+ end
data/license.txt ADDED
@@ -0,0 +1,18 @@
1
+ Copyright (c) 2006 Jon Egil Strand (jes@luretanker.no)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
4
+ this software and associated documentation files (the "Software"), to deal in
5
+ the Software without restriction, including without limitation the rights to
6
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
7
+ the Software, and to permit persons to whom the Software is furnished to do so,
8
+ subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in all
11
+ copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,56 +1,7 @@
1
- require 'date'
2
1
  require 'test/unit'
2
+ require 'lib/expanded_date'
3
3
 
4
- class Date
5
- def prev_month
6
- m = month - 1
7
- y = year
8
- if m == 0
9
- m = 12
10
- y = y - 1
11
- end
12
- d = day
13
- self::class.civil(y,m,d)
14
- end
15
-
16
- def next_month
17
- m = month + 1
18
- y = year
19
- if m == 13
20
- m = 1
21
- y = y + 1
22
- end
23
- d = day
24
- self::class.civil(y,m,d)
25
- end
26
-
27
- def end_of_month
28
- d = next_month
29
- self::class.civil(d.year, d.month, 1)-1
30
- end
31
-
32
- def beginning_of_month
33
- self::class.civil(self.year, self.month, 1)
34
- end
35
-
36
- def end_of_next_month
37
- self.beginning_of_month.next_month.end_of_month
38
- end
39
-
40
- def end_of_prev_month
41
- self.beginning_of_month-1
42
- end
43
-
44
- def beginning_of_next_month
45
- self.beginning_of_month.next_month
46
- end
47
-
48
- def beginning_of_prev_month
49
- self.beginning_of_month.prev_month
50
- end
51
- end
52
-
53
- class Datotest < Test::Unit::TestCase
4
+ class Datetest < Test::Unit::TestCase
54
5
  def test_next
55
6
  d = Date.parse("2000-01-01")
56
7
  assert_equal(d.to_s, "2000-01-01")
@@ -107,4 +58,4 @@ class Datotest < Test::Unit::TestCase
107
58
  assert_equal(Date.today.next_month.next_month.end_of_prev_month, Date.today.end_of_next_month)
108
59
  assert_equal(Date.today, Date.today.next_month.next_month.next_month.prev_month.prev_month.prev_month)
109
60
  end
110
- end
61
+ end
metadata CHANGED
@@ -3,21 +3,19 @@ rubygems_version: 0.9.0
3
3
  specification_version: 1
4
4
  name: expanded_date
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.1.1
7
- date: 2006-07-18 00:00:00 +02:00
6
+ version: 0.1.2
7
+ date: 2006-07-19 00:00:00 +02:00
8
8
  summary: Adds extra functionality to date
9
9
  require_paths:
10
10
  - lib
11
- - .
12
- - C:\ruby
13
- email:
11
+ email: jes@luretanker.no
14
12
  homepage:
15
13
  rubyforge_project:
16
14
  description:
17
15
  autorequire:
18
16
  default_executable:
19
17
  bindir: bin
20
- has_rdoc: false
18
+ has_rdoc: true
21
19
  required_ruby_version: !ruby/object:Gem::Version::Requirement
22
20
  requirements:
23
21
  - - ">"
@@ -28,16 +26,17 @@ platform: ruby
28
26
  signing_key:
29
27
  cert_chain:
30
28
  post_install_message:
31
- authors: []
32
-
29
+ authors:
30
+ - Jon Egil Strand
33
31
  files:
34
- - expanded_date.rb
32
+ - lib/expanded_date.rb
33
+ - license.txt
35
34
  test_files:
36
- - expanded_date.rb
35
+ - test/datetest.rb
37
36
  rdoc_options: []
38
37
 
39
- extra_rdoc_files: []
40
-
38
+ extra_rdoc_files:
39
+ - license.txt
41
40
  executables: []
42
41
 
43
42
  extensions: []