day and month confusion fixed
This commit is contained in:
parent
89839d059d
commit
de7b0ec90d
|
@ -8,8 +8,8 @@ class Page
|
|||
raise "must be partial, statr with _ not:#{base}" unless base[0] == "_"
|
||||
@words = base.split("-")
|
||||
@year = parse_int(@words.shift[1 .. -1] , 2100)
|
||||
@month = parse_int(@words.shift , 12)
|
||||
@day = parse_int(@words.shift , 32)
|
||||
@month = parse_int(@words.shift , 12)
|
||||
raise "Invalid path #{path}" unless @words
|
||||
end
|
||||
def slug
|
||||
|
@ -22,7 +22,7 @@ class Page
|
|||
"#{date}-#{@words.join("-")}"
|
||||
end
|
||||
def date
|
||||
"#{year}-#{month}-#{day}"
|
||||
"#{year}-#{day}-#{month}"
|
||||
end
|
||||
def parse_int( value , max)
|
||||
ret = value.to_i
|
||||
|
|
|
@ -27,8 +27,8 @@ RSpec.describe Page, type: :model do
|
|||
end
|
||||
it "returns dates" do
|
||||
expect(@page.year).to eq 1993
|
||||
expect(@page.month).to eq 2
|
||||
expect(@page.day).to eq 4
|
||||
expect(@page.month).to eq 4
|
||||
expect(@page.day).to eq 2
|
||||
end
|
||||
it "returns date" do
|
||||
expect(@page.date).to eq "1993-2-4"
|
||||
|
|
Loading…
Reference in New Issue