Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stink #1

Merged
merged 2 commits into from
Dec 31, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions lib/new_base_60.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -39,12 +39,7 @@ def to_i


# Converts into a Date. # Converts into a Date.
def to_date def to_date
# HACK this is smelly Time.at(to_i * 60 * 60 * 24).utc.to_date
# days since epoch * seconds * minutes * hours + timezone
time = Time.at(NewBase60.new(@base_60).to_i *
60 * 60 * 24 + Time.now.gmtoff.abs)

Date.parse(time.strftime("%Y/%m/%d"))
end end
end end


Expand Down
2 changes: 2 additions & 0 deletions test/test_new_base_60.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ def test_base60_to_base10
end end


def test_base60_to_date def test_base60_to_date
assert NewBase60.new("").to_date == Date.parse("1970/01/01")
assert NewBase60.new("4JG").to_date == Date.parse("2012/06/05")
assert NewBase60.new("464").to_date == Date.parse("2010/06/04") assert NewBase60.new("464").to_date == Date.parse("2010/06/04")
refute NewBase60.new("464").to_date == Date.parse("2010/06/05") refute NewBase60.new("464").to_date == Date.parse("2010/06/05")
end end
Expand Down