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