mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 05:09:38 +02:00
Fix chart timezone bug (#2224)
This commit is contained in:
parent
2707a40a2a
commit
ea1b6f2bd8
1 changed files with 10 additions and 10 deletions
|
@ -11,55 +11,55 @@ class Period
|
||||||
|
|
||||||
PERIODS = {
|
PERIODS = {
|
||||||
"last_day" => {
|
"last_day" => {
|
||||||
date_range: [ 1.day.ago.to_date, Date.current ],
|
date_range: -> { [ 1.day.ago.to_date, Date.current ] },
|
||||||
label_short: "1D",
|
label_short: "1D",
|
||||||
label: "Last Day",
|
label: "Last Day",
|
||||||
comparison_label: "vs. yesterday"
|
comparison_label: "vs. yesterday"
|
||||||
},
|
},
|
||||||
"current_week" => {
|
"current_week" => {
|
||||||
date_range: [ Date.current.beginning_of_week, Date.current ],
|
date_range: -> { [ Date.current.beginning_of_week, Date.current ] },
|
||||||
label_short: "WTD",
|
label_short: "WTD",
|
||||||
label: "Current Week",
|
label: "Current Week",
|
||||||
comparison_label: "vs. start of week"
|
comparison_label: "vs. start of week"
|
||||||
},
|
},
|
||||||
"last_7_days" => {
|
"last_7_days" => {
|
||||||
date_range: [ 7.days.ago.to_date, Date.current ],
|
date_range: -> { [ 7.days.ago.to_date, Date.current ] },
|
||||||
label_short: "7D",
|
label_short: "7D",
|
||||||
label: "Last 7 Days",
|
label: "Last 7 Days",
|
||||||
comparison_label: "vs. last week"
|
comparison_label: "vs. last week"
|
||||||
},
|
},
|
||||||
"current_month" => {
|
"current_month" => {
|
||||||
date_range: [ Date.current.beginning_of_month, Date.current ],
|
date_range: -> { [ Date.current.beginning_of_month, Date.current ] },
|
||||||
label_short: "MTD",
|
label_short: "MTD",
|
||||||
label: "Current Month",
|
label: "Current Month",
|
||||||
comparison_label: "vs. start of month"
|
comparison_label: "vs. start of month"
|
||||||
},
|
},
|
||||||
"last_30_days" => {
|
"last_30_days" => {
|
||||||
date_range: [ 30.days.ago.to_date, Date.current ],
|
date_range: -> { [ 30.days.ago.to_date, Date.current ] },
|
||||||
label_short: "30D",
|
label_short: "30D",
|
||||||
label: "Last 30 Days",
|
label: "Last 30 Days",
|
||||||
comparison_label: "vs. last month"
|
comparison_label: "vs. last month"
|
||||||
},
|
},
|
||||||
"last_90_days" => {
|
"last_90_days" => {
|
||||||
date_range: [ 90.days.ago.to_date, Date.current ],
|
date_range: -> { [ 90.days.ago.to_date, Date.current ] },
|
||||||
label_short: "90D",
|
label_short: "90D",
|
||||||
label: "Last 90 Days",
|
label: "Last 90 Days",
|
||||||
comparison_label: "vs. last quarter"
|
comparison_label: "vs. last quarter"
|
||||||
},
|
},
|
||||||
"current_year" => {
|
"current_year" => {
|
||||||
date_range: [ Date.current.beginning_of_year, Date.current ],
|
date_range: -> { [ Date.current.beginning_of_year, Date.current ] },
|
||||||
label_short: "YTD",
|
label_short: "YTD",
|
||||||
label: "Current Year",
|
label: "Current Year",
|
||||||
comparison_label: "vs. start of year"
|
comparison_label: "vs. start of year"
|
||||||
},
|
},
|
||||||
"last_365_days" => {
|
"last_365_days" => {
|
||||||
date_range: [ 365.days.ago.to_date, Date.current ],
|
date_range: -> { [ 365.days.ago.to_date, Date.current ] },
|
||||||
label_short: "365D",
|
label_short: "365D",
|
||||||
label: "Last 365 Days",
|
label: "Last 365 Days",
|
||||||
comparison_label: "vs. 1 year ago"
|
comparison_label: "vs. 1 year ago"
|
||||||
},
|
},
|
||||||
"last_5_years" => {
|
"last_5_years" => {
|
||||||
date_range: [ 5.years.ago.to_date, Date.current ],
|
date_range: -> { [ 5.years.ago.to_date, Date.current ] },
|
||||||
label_short: "5Y",
|
label_short: "5Y",
|
||||||
label: "Last 5 Years",
|
label: "Last 5 Years",
|
||||||
comparison_label: "vs. 5 years ago"
|
comparison_label: "vs. 5 years ago"
|
||||||
|
@ -72,7 +72,7 @@ class Period
|
||||||
raise InvalidKeyError, "Invalid period key: #{key}"
|
raise InvalidKeyError, "Invalid period key: #{key}"
|
||||||
end
|
end
|
||||||
|
|
||||||
start_date, end_date = PERIODS[key].fetch(:date_range)
|
start_date, end_date = PERIODS[key].fetch(:date_range).call
|
||||||
|
|
||||||
new(key: key, start_date: start_date, end_date: end_date)
|
new(key: key, start_date: start_date, end_date: end_date)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue