Skip to content

Commit

Permalink
Let load_localtime use read_zoneinfo directly
Browse files Browse the repository at this point in the history
  • Loading branch information
straight-shoota committed Nov 30, 2017
1 parent 0a47de5 commit 7e6ecc6
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/crystal/system/unix/time.cr
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,17 @@ module Crystal::System::Time
"/usr/share/lib/zoneinfo/",
"/usr/lib/locale/TZ/",
}
LOCALTIME = "/etc/localtime"

def self.zone_sources
ZONE_SOURCES
end

def self.load_localtime
if location = ::Time::Location.load("localtime", ["/etc/"])
location.name = "Local"
return location
if File.exists?(LOCALTIME)
File.open(LOCALTIME) do |file|
::Time::Location.read_zoneinfo("Local", file)
end
end
end

Expand Down

0 comments on commit 7e6ecc6

Please sign in to comment.