Skip to content

Commit

Permalink
Improved strftime performance for UTC timezone
Browse files Browse the repository at this point in the history
  • Loading branch information
gaspard committed Sep 19, 2012
1 parent f2011c7 commit dbeaa58
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions lib/zena/use/dates.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,8 @@ module TimeMethods
def strftime_tz(format, tz = nil)
if tz.blank?
tz = visitor.tz
elsif tz == 'UTC'
return self.strftime(format.to_s)
elsif tz.kind_of?(String)
tz = TZInfo::Timezone.get(tz)
end
Expand All @@ -301,6 +303,8 @@ def strftime_tz(format, tz = nil)
def year_tz(tz = nil)
if tz.blank?
tz = visitor.tz
elsif tz == 'UTC'
return self.year
elsif tz.kind_of?(String)
tz = TZInfo::Timezone.get(tz)
end
Expand All @@ -314,6 +318,8 @@ def year_tz(tz = nil)
def advance_tz(opts, tz = nil)
if tz.blank?
tz = visitor.tz
elsif tz == 'UTC'
return self.advance(opts)
elsif tz.kind_of?(String)
tz = TZInfo::Timezone.get(tz)
end
Expand All @@ -327,6 +333,8 @@ def advance_tz(opts, tz = nil)
def wday_tz(tz = nil)
if tz.blank?
tz = visitor.tz
elsif tz == 'UTC'
return self.wday
elsif tz.kind_of?(String)
tz = TZInfo::Timezone.get(tz)
end
Expand All @@ -340,6 +348,8 @@ def wday_tz(tz = nil)
def to_date_tz(tz = nil)
if tz.blank?
tz = visitor.tz
elsif tz == 'UTC'
return self.to_date
elsif tz.kind_of?(String)
tz = TZInfo::Timezone.get(tz)
end
Expand Down

0 comments on commit dbeaa58

Please sign in to comment.