Merge pull request #268 from gboudreau/fix/gh-194-timespans-in-negative-tz

Bugfix: when calculating the timestamp (for months and years), ignore the Timezone
This commit is contained in:
Evgenii Burmakin 2024-09-28 18:17:22 +03:00 committed by GitHub
commit d76e1a4052
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -11,14 +11,14 @@ module ApplicationHelper
end
def year_timespan(year)
start_at = Time.utc(year).in_time_zone(Time.zone).beginning_of_year.strftime('%Y-%m-%dT%H:%M')
end_at = Time.utc(year).in_time_zone(Time.zone).end_of_year.strftime('%Y-%m-%dT%H:%M')
start_at = Time.new(year).beginning_of_year.strftime('%Y-%m-%dT%H:%M')
end_at = Time.new(year).end_of_year.strftime('%Y-%m-%dT%H:%M')
{ start_at:, end_at: }
end
def timespan(month, year)
month = DateTime.new(year, month).in_time_zone(Time.zone)
month = DateTime.new(year, month)
start_at = month.beginning_of_month.to_time.strftime('%Y-%m-%dT%H:%M')
end_at = month.end_of_month.to_time.strftime('%Y-%m-%dT%H:%M')