smart_month 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.
Files changed (90) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README +33 -0
  3. data/Rakefile +51 -0
  4. data/VERSION +1 -0
  5. data/lib/month.rb +26 -0
  6. data/lib/smart_month.rb +11 -0
  7. data/lib/smart_month/calculations.rb +87 -0
  8. data/lib/smart_month/collection.rb +51 -0
  9. data/lib/smart_month/extensions/date.rb +19 -0
  10. data/lib/smart_month/magic.rb +71 -0
  11. data/lib/smart_month/math.rb +41 -0
  12. data/lib/smart_month/rulesets.rb +151 -0
  13. data/lib/smart_month/util.rb +37 -0
  14. data/pkg/smart_month-1.0.0.gem +0 -0
  15. data/rdoc/classes/Date.html +209 -0
  16. data/rdoc/classes/Month.html +189 -0
  17. data/rdoc/classes/SmartMonth.html +136 -0
  18. data/rdoc/classes/SmartMonth/Calculations.html +383 -0
  19. data/rdoc/classes/SmartMonth/Collection.html +306 -0
  20. data/rdoc/classes/SmartMonth/Magic.html +214 -0
  21. data/rdoc/classes/SmartMonth/Magic/MonthFactory.html +178 -0
  22. data/rdoc/classes/SmartMonth/Math.html +311 -0
  23. data/rdoc/classes/SmartMonth/Rulesets.html +419 -0
  24. data/rdoc/classes/SmartMonth/Util.html +302 -0
  25. data/rdoc/classes/Time.html +152 -0
  26. data/rdoc/created.rid +1 -0
  27. data/rdoc/files/README.html +170 -0
  28. data/rdoc/files/lib/month_rb.html +113 -0
  29. data/rdoc/files/lib/smart_month/calculations_rb.html +101 -0
  30. data/rdoc/files/lib/smart_month/collection_rb.html +101 -0
  31. data/rdoc/files/lib/smart_month/extensions/date_rb.html +108 -0
  32. data/rdoc/files/lib/smart_month/magic_rb.html +101 -0
  33. data/rdoc/files/lib/smart_month/math_rb.html +101 -0
  34. data/rdoc/files/lib/smart_month/rulesets_rb.html +108 -0
  35. data/rdoc/files/lib/smart_month/util_rb.html +101 -0
  36. data/rdoc/files/lib/smart_month_rb.html +108 -0
  37. data/rdoc/fr_class_index.html +37 -0
  38. data/rdoc/fr_file_index.html +36 -0
  39. data/rdoc/fr_method_index.html +74 -0
  40. data/rdoc/index.html +24 -0
  41. data/rdoc/rdoc-style.css +208 -0
  42. data/smart_month.gemspec +179 -0
  43. data/test/spec/date/accessor_spec.rb +91 -0
  44. data/test/spec/date/add_month_spec.rb +24 -0
  45. data/test/spec/date/add_spec.rb +23 -0
  46. data/test/spec/date/boat_spec.rb +20 -0
  47. data/test/spec/date/civil_spec.rb +28 -0
  48. data/test/spec/date/commercial_spec.rb +29 -0
  49. data/test/spec/date/constants_spec.rb +41 -0
  50. data/test/spec/date/conversions_spec.rb +153 -0
  51. data/test/spec/date/downto_spec.rb +18 -0
  52. data/test/spec/date/eql_spec.rb +10 -0
  53. data/test/spec/date/gregorian_spec.rb +28 -0
  54. data/test/spec/date/hash_spec.rb +14 -0
  55. data/test/spec/date/infinity_spec.rb +77 -0
  56. data/test/spec/date/julian_spec.rb +52 -0
  57. data/test/spec/date/minus_month_spec.rb +23 -0
  58. data/test/spec/date/minus_spec.rb +30 -0
  59. data/test/spec/date/new_spec.rb +9 -0
  60. data/test/spec/date/neww_spec.rb +9 -0
  61. data/test/spec/date/ordinal_spec.rb +29 -0
  62. data/test/spec/date/parse_spec.rb +149 -0
  63. data/test/spec/date/relationship_spec.rb +20 -0
  64. data/test/spec/date/shared/civil.rb +66 -0
  65. data/test/spec/date/shared/commercial.rb +39 -0
  66. data/test/spec/date/shared/parse.rb +54 -0
  67. data/test/spec/date/shared/parse_eu.rb +30 -0
  68. data/test/spec/date/shared/parse_us.rb +29 -0
  69. data/test/spec/date/step_spec.rb +56 -0
  70. data/test/spec/date/strftime_spec.rb +205 -0
  71. data/test/spec/date/strptime_spec.rb +143 -0
  72. data/test/spec/date/upto_spec.rb +18 -0
  73. data/test/spec/parsedate/parsedate.rb +95 -0
  74. data/test/spec/time/httpdate_spec.rb +21 -0
  75. data/test/spec/time/iso8601_spec.rb +7 -0
  76. data/test/spec/time/rfc2822_spec.rb +7 -0
  77. data/test/spec/time/rfc822_spec.rb +7 -0
  78. data/test/spec/time/shared/rfc2822.rb +65 -0
  79. data/test/spec/time/shared/xmlschema.rb +53 -0
  80. data/test/spec/time/xmlschema_spec.rb +7 -0
  81. data/test/spec_helper.rb +56 -0
  82. data/test/test_helper.rb +4 -0
  83. data/test/unit/calculations_test.rb +82 -0
  84. data/test/unit/collection_test.rb +42 -0
  85. data/test/unit/magic_test.rb +37 -0
  86. data/test/unit/math_test.rb +30 -0
  87. data/test/unit/rulesets_test.rb +94 -0
  88. data/test/unit/samples/test_ruleset.yml +6 -0
  89. data/test/unit/util_test.rb +29 -0
  90. metadata +196 -0
@@ -0,0 +1,20 @@
1
+ require 'date'
2
+ require File.dirname(__FILE__) + '/../../spec_helper'
3
+
4
+ describe "Date#===" do
5
+
6
+ it "should be able to compare two same dates" do
7
+ (Date.civil(2000, 04, 06) <=> Date.civil(2000, 04, 06)).should == 0
8
+ end
9
+
10
+ it "should be able to compute the difference between two dates" do
11
+ (Date.civil(2000, 04, 05) <=> Date.civil(2000, 04, 06)).should == -1
12
+ (Date.civil(2001, 04, 05) <=> Date.civil(2000, 04, 06)).should == 1
13
+ end
14
+
15
+ it "should be able to compare to another numeric" do
16
+ (Date.civil(2000, 04, 05) <=> Date.civil(2000, 04, 06).jd).should == -1
17
+ (Date.civil(2001, 04, 05) <=> Date.civil(2000, 04, 06).jd).should == 1
18
+ end
19
+
20
+ end
@@ -0,0 +1,66 @@
1
+ describe :date_civil, :shared => true do
2
+ it "creates a Date for -4712 by default" do
3
+ # the #chomp calls are necessary because of RSpec
4
+ d = Date.send(@method)
5
+ d.year.should == -4712
6
+ d.month.should == 1
7
+ d.day.should == 1
8
+ d.julian?.should == true
9
+ d.jd.should == 0
10
+ end
11
+
12
+ it "creates a date with arguments" do
13
+ d = Date.send(@method, 2000, 3, 5)
14
+ d.year.should == 2000
15
+ d.month.should == 3
16
+ d.day.should == 5
17
+ d.julian?.should == false
18
+ d.jd.should == 2451609
19
+
20
+ # Should also work with years far in the past and future
21
+
22
+ d = Date.send(@method, -9000, 7, 5)
23
+ d.year.should == -9000
24
+ d.month.should == 7
25
+ d.day.should == 5
26
+ d.julian?.should == true
27
+ d.jd.should == -1566006
28
+
29
+ d = Date.send(@method, 9000, 10, 14)
30
+ d.year.should == 9000
31
+ d.month.should == 10
32
+ d.day.should == 14
33
+ d.julian?.should == false
34
+ d.jd.should == 5008529
35
+
36
+ end
37
+
38
+ it "doesn't create dates for invalid arguments" do
39
+ lambda { Date.send(@method, 2000, 13, 31) }.should raise_error(ArgumentError)
40
+ lambda { Date.send(@method, 2000, 12, 32) }.should raise_error(ArgumentError)
41
+ lambda { Date.send(@method, 2000, 2, 30) }.should raise_error(ArgumentError)
42
+ lambda { Date.send(@method, 1900, 2, 29) }.should raise_error(ArgumentError)
43
+ lambda { Date.send(@method, 2000, 2, 29) }.should_not raise_error(ArgumentError)
44
+
45
+ lambda { Date.send(@method, 1582, 10, 14) }.should raise_error(ArgumentError)
46
+ lambda { Date.send(@method, 1582, 10, 15) }.should_not raise_error(ArgumentError)
47
+
48
+ end
49
+
50
+ it "creats a Date for different calendar reform dates" do
51
+ d1 = Date.send(@method, 1582, 10, 4)
52
+ d1.succ.day.should == 15
53
+
54
+ d2 = Date.send(@method, 1582, 10, 4, Date::ENGLAND)
55
+ d2.succ.day.should == 5
56
+
57
+ # Choose an arbitrary reform date
58
+ r = Date.send(@method, 2000, 2, 3)
59
+
60
+ d3 = Date.send(@method, 2000, 2, 3, r.jd)
61
+ (d3 - 1).day.should == 20
62
+ (d3 - 1).month.should == 1
63
+
64
+ lambda { Date.send(@method, 2000, 2, 2, r.jd) }.should raise_error(ArgumentError)
65
+ end
66
+ end
@@ -0,0 +1,39 @@
1
+ describe :date_commercial, :shared => true do
2
+ it "creates a Date for the day of Julian calendar reform in Italy by default" do
3
+ d = Date.send(@method)
4
+ d.year.should == 1582
5
+ d.month.should == 10
6
+ d.day.should == 15
7
+ end
8
+
9
+ it "Creates a Date for the friday in the year and week given" do
10
+ d = Date.send(@method, 2000, 1)
11
+ d.year.should == 2000
12
+ d.month.should == 1
13
+ d.day.should == 7
14
+ d.cwday.should == 5
15
+ end
16
+
17
+ it "Creates a Date for the correct day given the year, week and day number" do
18
+ d = Date.send(@method, 2004, 1, 1)
19
+ d.year.should == 2003
20
+ d.month.should == 12
21
+ d.day.should == 29
22
+ d.cwday.should == 1
23
+ d.cweek.should == 1
24
+ d.cwyear.should == 2004
25
+ end
26
+
27
+ it "creates only Date objects for valid weeks" do
28
+ lambda { Date.send(@method, 2004, 53, 1) }.should_not raise_error(ArgumentError)
29
+ lambda { Date.send(@method, 2004, 53, 0) }.should raise_error(ArgumentError)
30
+ lambda { Date.send(@method, 2004, 53, 8) }.should raise_error(ArgumentError)
31
+ lambda { Date.send(@method, 2004, 54, 1) }.should raise_error(ArgumentError)
32
+ lambda { Date.send(@method, 2004, 0, 1) }.should raise_error(ArgumentError)
33
+
34
+ lambda { Date.send(@method, 2003, 52, 1) }.should_not raise_error(ArgumentError)
35
+ lambda { Date.send(@method, 2003, 53, 1) }.should raise_error(ArgumentError)
36
+ lambda { Date.send(@method, 2003, 52, 0) }.should raise_error(ArgumentError)
37
+ lambda { Date.send(@method, 2003, 52, 8) }.should raise_error(ArgumentError)
38
+ end
39
+ end
@@ -0,0 +1,54 @@
1
+ describe :date_parse, :shared => true do
2
+ it "can parse a mmm-YYYY string into a Date object" do
3
+ d = Date.parse("feb#{@sep}2008")
4
+ d.year.should == 2008
5
+ d.month.should == 2
6
+ d.day.should == 1
7
+ end
8
+
9
+ it "can parse a 'DD mmm YYYY' string into a Date object" do
10
+ d = Date.parse("23#{@sep}feb#{@sep}2008")
11
+ d.year.should == 2008
12
+ d.month.should == 2
13
+ d.day.should == 23
14
+ end
15
+
16
+ it "can parse a 'mmm DD YYYY' string into a Date object" do
17
+ d = Date.parse("23#{@sep}feb#{@sep}2008")
18
+ d.year.should == 2008
19
+ d.month.should == 2
20
+ d.day.should == 23
21
+ end
22
+
23
+ it "can parse a 'YYYY mmm DD' string into a Date object" do
24
+ d = Date.parse("2008#{@sep}feb#{@sep}23")
25
+ d.year.should == 2008
26
+ d.month.should == 2
27
+ d.day.should == 23
28
+ end
29
+
30
+ it "can parse a month name and day into a Date object" do
31
+ d = Date.parse("november#{@sep}5th")
32
+ d.should == Date.civil(Date.today.year, 11, 5)
33
+ end
34
+
35
+ it "can parse a month name, day and year into a Date object" do
36
+ d = Date.parse("november#{@sep}5th#{@sep}2005")
37
+ d.should == Date.civil(2005, 11, 5)
38
+ end
39
+
40
+ it "can parse a year, month name and day into a Date object" do
41
+ d = Date.parse("2005#{@sep}november#{@sep}5th")
42
+ d.should == Date.civil(2005, 11, 5)
43
+ end
44
+
45
+ it "can parse a year, day and month name into a Date object" do
46
+ d = Date.parse("5th#{@sep}november#{@sep}2005")
47
+ d.should == Date.civil(2005, 11, 5)
48
+ end
49
+
50
+ it "can handle negative year numbers" do
51
+ d = Date.parse("5th#{@sep}november#{@sep}-2005")
52
+ d.should == Date.civil(-2005, 11, 5)
53
+ end
54
+ end
@@ -0,0 +1,30 @@
1
+ describe :date_parse_eu, :shared => true do
2
+ # The - separator let's it work like European format, so it as a different spec
3
+ it "can parse a YYYY-MM-DD string into a Date object" do
4
+ d = Date.parse("2007#{@sep}10#{@sep}01")
5
+ d.year.should == 2007
6
+ d.month.should == 10
7
+ d.day.should == 1
8
+ end
9
+
10
+ it "can parse a MM-DD-YYYY string into a Date object" do
11
+ d = Date.parse("10#{@sep}01#{@sep}2007")
12
+ d.year.should == 2007
13
+ d.month.should == 1
14
+ d.day.should == 10
15
+ end
16
+
17
+ it "can parse a MM-DD-YY string into a Date object" do
18
+ d = Date.parse("10#{@sep}01#{@sep}07")
19
+ d.year.should == 10
20
+ d.month.should == 1
21
+ d.day.should == 7
22
+ end
23
+
24
+ it "can parse a MM-DD-YY string into a Date object using the year digits as 20XX" do
25
+ d = Date.parse("10#{@sep}01#{@sep}07", true)
26
+ d.year.should == 2010
27
+ d.month.should == 1
28
+ d.day.should == 7
29
+ end
30
+ end
@@ -0,0 +1,29 @@
1
+ describe :date_parse_us, :shared => true do
2
+ it "parses a YYYY#{@sep}MM#{@sep}DD string into a Date object" do
3
+ d = Date.parse("2007#{@sep}10#{@sep}01")
4
+ d.year.should == 2007
5
+ d.month.should == 10
6
+ d.day.should == 1
7
+ end
8
+
9
+ it "parses a MM#{@sep}DD#{@sep}YYYY string into a Date object" do
10
+ d = Date.parse("10#{@sep}01#{@sep}2007")
11
+ d.year.should == 2007
12
+ d.month.should == 10
13
+ d.day.should == 1
14
+ end
15
+
16
+ it "parses a MM#{@sep}DD#{@sep}YY string into a Date object" do
17
+ d = Date.parse("10#{@sep}01#{@sep}07")
18
+ d.year.should == 7
19
+ d.month.should == 10
20
+ d.day.should == 1
21
+ end
22
+
23
+ it "parses a MM#{@sep}DD#{@sep}YY string into a Date object using the year digits as 20XX" do
24
+ d = Date.parse("10#{@sep}01#{@sep}07", true)
25
+ d.year.should == 2007
26
+ d.month.should == 10
27
+ d.day.should == 1
28
+ end
29
+ end
@@ -0,0 +1,56 @@
1
+ require 'date'
2
+ require File.dirname(__FILE__) + '/../../spec_helper'
3
+
4
+ describe "Date#step" do
5
+
6
+ it "should be able to step forward in time" do
7
+ ds = Date.civil(2008, 10, 11)
8
+ de = Date.civil(2008, 9, 29)
9
+ count = 0
10
+ de.step(ds) do |d|
11
+ d.should <= ds
12
+ d.should >= de
13
+ count += 1
14
+ end
15
+ count.should == 13
16
+
17
+ count = 0
18
+ de.step(ds, 5) do |d|
19
+ d.should <= ds
20
+ d.should >= de
21
+ count += 1
22
+ end
23
+ count.should == 3
24
+
25
+ count = 0
26
+ ds.step(de) do |d|; count += 1; end
27
+ count.should == 0
28
+
29
+ end
30
+
31
+ it "should be able to step backward in time" do
32
+ ds = Date.civil(2000, 4, 14)
33
+ de = Date.civil(2000, 3, 29)
34
+ count = 0
35
+ ds.step(de, -1) do |d|
36
+ d.should <= ds
37
+ d.should >= de
38
+ count += 1
39
+ end
40
+ count.should == 17
41
+
42
+ count = 0
43
+ ds.step(de, -5) do |d|
44
+ d.should <= ds
45
+ d.should >= de
46
+ count += 1
47
+ end
48
+ count.should == 4
49
+
50
+ count = 0
51
+ de.step(ds, -1) do |d|; count += 1; end
52
+ count.should == 0
53
+
54
+ end
55
+
56
+ end
@@ -0,0 +1,205 @@
1
+ require 'date'
2
+ require File.dirname(__FILE__) + '/../../spec_helper'
3
+
4
+ describe "Date#strftime" do
5
+
6
+ it "should be able to print the date" do
7
+ Date.civil(2000, 4, 6).strftime.should == "2000-04-06"
8
+ Date.civil(2000, 4, 6).strftime.should == Date.civil(2000, 4, 6).to_s
9
+ end
10
+
11
+ it "should be able to print the full day name" do
12
+ Date.civil(2000, 4, 6).strftime("%A").should == "Thursday"
13
+ end
14
+
15
+ it "should be able to print the short day name" do
16
+ Date.civil(2000, 4, 6).strftime("%a").should == "Thu"
17
+ end
18
+
19
+ it "should be able to print the full month name" do
20
+ Date.civil(2000, 4, 6).strftime("%B").should == "April"
21
+ end
22
+
23
+ it "should be able to print the short month name" do
24
+ Date.civil(2000, 4, 6).strftime("%b").should == "Apr"
25
+ Date.civil(2000, 4, 6).strftime("%h").should == "Apr"
26
+ Date.civil(2000, 4, 6).strftime("%b").should == Date.civil(2000, 4, 6).strftime("%h")
27
+ end
28
+
29
+ it "should be able to print the century" do
30
+ Date.civil(2000, 4, 6).strftime("%C").should == "20"
31
+ end
32
+
33
+ it "should be able to print the month day with leading zeroes" do
34
+ Date.civil(2000, 4, 6).strftime("%d").should == "06"
35
+ end
36
+
37
+ it "should be able to print the month day with leading spaces" do
38
+ Date.civil(2000, 4, 6).strftime("%e").should == " 6"
39
+ end
40
+
41
+ it "should be able to print the commercial year with leading zeroes" do
42
+ Date.civil(2000, 4, 6).strftime("%G").should == "2000"
43
+ Date.civil( 200, 4, 6).strftime("%G").should == "0200"
44
+ end
45
+
46
+ it "should be able to print the commercial year with only two digits" do
47
+ Date.civil(2000, 4, 6).strftime("%g").should == "00"
48
+ Date.civil( 200, 4, 6).strftime("%g").should == "00"
49
+ end
50
+
51
+ it "should be able to print the hour with leading zeroes (hour is always 00)" do
52
+ Date.civil(2000, 4, 6).strftime("%H").should == "00"
53
+ end
54
+
55
+ it "should be able to print the hour in 12 hour notation with leading zeroes" do
56
+ Date.civil(2000, 4, 6).strftime("%I").should == "12"
57
+ end
58
+
59
+ it "should be able to print the year day with leading zeroes" do
60
+ Date.civil(2000, 4, 6).strftime("%j").should == "097"
61
+ end
62
+
63
+ it "should be able to print the hour in 24 hour notation with leading spaces" do
64
+ Date.civil(2000, 4, 6).strftime("%k").should == " 0"
65
+ end
66
+
67
+ it "should be able to print the hour in 12 hour notation with leading spaces" do
68
+ Date.civil(2000, 4, 6).strftime("%l").should == "12"
69
+ end
70
+
71
+ it "should be able to print the minutes with leading zeroes" do
72
+ Date.civil(2000, 4, 6).strftime("%M").should == "00"
73
+ end
74
+
75
+ it "should be able to print the month with leading zeroes" do
76
+ Date.civil(2000, 4, 6).strftime("%m").should == "04"
77
+ end
78
+
79
+ it "should be able to add a newline" do
80
+ Date.civil(2000, 4, 6).strftime("%n").should == "\n"
81
+ end
82
+
83
+ it "should be able to show AM/PM" do
84
+ Date.civil(2000, 4, 6).strftime("%P").should == "am"
85
+ end
86
+
87
+ it "should be able to show am/pm" do
88
+ Date.civil(2000, 4, 6).strftime("%p").should == "AM"
89
+ end
90
+
91
+ it "should be able to show the number of seconds with leading zeroes" do
92
+ Date.civil(2000, 4, 6).strftime("%S").should == "00"
93
+ end
94
+
95
+ it "should be able to show the number of seconds with leading zeroes" do
96
+ Date.civil(2000, 4, 6).strftime("%S").should == "00"
97
+ end
98
+
99
+ it "should be able to show the number of seconds since the unix epoch" do
100
+ Date.civil(2000, 4, 6).strftime("%s").should == "954979200"
101
+ end
102
+
103
+ it "should be able to add a tab" do
104
+ Date.civil(2000, 4, 6).strftime("%t").should == "\t"
105
+ end
106
+
107
+ it "should be able to show the week number with the week starting on sunday and monday" do
108
+ Date.civil(2000, 4, 6).strftime("%U").should == "14"
109
+ Date.civil(2000, 4, 6).strftime("%W").should == "14"
110
+ Date.civil(2000, 4, 6).strftime("%U").should == Date.civil(2000, 4, 6).strftime("%W")
111
+ Date.civil(2000, 4, 9).strftime("%U").should == "15"
112
+ Date.civil(2000, 4, 9).strftime("%W").should == "14"
113
+ Date.civil(2000, 4, 9).strftime("%U").should_not == Date.civil(2000, 4, 9).strftime("%W")
114
+ end
115
+
116
+ it "should be able to show the commercial week day" do
117
+ Date.civil(2000, 4, 9).strftime("%u").should == "7"
118
+ Date.civil(2000, 4, 10).strftime("%u").should == "1"
119
+ end
120
+
121
+ it "should be able to show the commercial week" do
122
+ Date.civil(2000, 4, 9).strftime("%V").should == "14"
123
+ Date.civil(2000, 4, 10).strftime("%V").should == "15"
124
+ end
125
+
126
+ it "should be able to show the week day" do
127
+ Date.civil(2000, 4, 9).strftime("%w").should == "0"
128
+ Date.civil(2000, 4, 10).strftime("%w").should == "1"
129
+ end
130
+
131
+ it "should be able to show the year in YYYY format" do
132
+ Date.civil(2000, 4, 9).strftime("%Y").should == "2000"
133
+ end
134
+
135
+ it "should be able to show the year in YY format" do
136
+ Date.civil(2000, 4, 9).strftime("%y").should == "00"
137
+ end
138
+
139
+ it "should be able to show the timezone of the date with a : separator" do
140
+ Date.civil(2000, 4, 9).strftime("%Z").should == "+00:00"
141
+ end
142
+
143
+ it "should be able to show the timezone of the date with a : separator" do
144
+ Date.civil(2000, 4, 9).strftime("%z").should == "+0000"
145
+ end
146
+
147
+ it "should be able to escape the % character" do
148
+ Date.civil(2000, 4, 9).strftime("%%").should == "%"
149
+ end
150
+
151
+ ############################
152
+ # Specs that combine stuff #
153
+ ############################
154
+
155
+ it "should be able to print the date in full" do
156
+ Date.civil(2000, 4, 6).strftime("%c").should == "Thu Apr 6 00:00:00 2000"
157
+ Date.civil(2000, 4, 6).strftime("%c").should == Date.civil(2000, 4, 6).strftime('%a %b %e %H:%M:%S %Y')
158
+ end
159
+
160
+ it "should be able to print the date with slashes" do
161
+ Date.civil(2000, 4, 6).strftime("%D").should == "04/06/00"
162
+ Date.civil(2000, 4, 6).strftime("%D").should == Date.civil(2000, 4, 6).strftime('%m/%d/%y')
163
+ end
164
+
165
+ it "should be able to print the date as YYYY-MM-DD" do
166
+ Date.civil(2000, 4, 6).strftime("%F").should == "2000-04-06"
167
+ Date.civil(2000, 4, 6).strftime("%F").should == Date.civil(2000, 4, 6).strftime('%Y-%m-%d')
168
+ end
169
+
170
+ it "should be able to show HH:MM" do
171
+ Date.civil(2000, 4, 6).strftime("%R").should == "00:00"
172
+ Date.civil(2000, 4, 6).strftime("%R").should == Date.civil(2000, 4, 6).strftime('%H:%M')
173
+ end
174
+
175
+ it "should be able to show HH:MM:SS AM/PM" do
176
+ Date.civil(2000, 4, 6).strftime("%r").should == "12:00:00 AM"
177
+ Date.civil(2000, 4, 6).strftime("%r").should == Date.civil(2000, 4, 6).strftime('%I:%M:%S %p')
178
+ end
179
+
180
+ it "should be able to show HH:MM:SS" do
181
+ Date.civil(2000, 4, 6).strftime("%T").should == "00:00:00"
182
+ Date.civil(2000, 4, 6).strftime("%T").should == Date.civil(2000, 4, 6).strftime('%H:%M:%S')
183
+ end
184
+
185
+ it "should be able to show the commercial week" do
186
+ Date.civil(2000, 4, 9).strftime("%v").should == " 9-Apr-2000"
187
+ Date.civil(2000, 4, 9).strftime("%v").should == Date.civil(2000, 4, 9).strftime('%e-%b-%Y')
188
+ end
189
+
190
+ it "should be able to show HH:MM:SS" do
191
+ Date.civil(2000, 4, 6).strftime("%X").should == "00:00:00"
192
+ Date.civil(2000, 4, 6).strftime("%X").should == Date.civil(2000, 4, 6).strftime('%H:%M:%S')
193
+ end
194
+
195
+ it "should be able to show MM/DD/YY" do
196
+ Date.civil(2000, 4, 6).strftime("%x").should == "04/06/00"
197
+ Date.civil(2000, 4, 6).strftime("%x").should == Date.civil(2000, 4, 6).strftime('%m/%d/%y')
198
+ end
199
+
200
+ it "should be able to show a full notation" do
201
+ Date.civil(2000, 4, 9).strftime("%+").should == "Sun Apr 9 00:00:00 +00:00 2000"
202
+ Date.civil(2000, 4, 9).strftime("%+").should == Date.civil(2000, 4, 9).strftime('%a %b %e %H:%M:%S %Z %Y')
203
+ end
204
+
205
+ end