Browse Source
- We previously pushed logs into archives categorised by the quarter that they were created for. - CDS requested that instead we push everything into a larger bucket seperated by FY.pull/1319/head
James Rose
2 years ago
committed by
GitHub
5 changed files with 69 additions and 19 deletions
@ -1,16 +1,26 @@ |
|||||||
module CollectionTimeHelper |
module CollectionTimeHelper |
||||||
|
def collection_start_year(date) |
||||||
|
window_end_date = Time.zone.local(date.year, 4, 1) |
||||||
|
date < window_end_date ? date.year - 1 : date.year |
||||||
|
end |
||||||
|
|
||||||
def current_collection_start_year |
def current_collection_start_year |
||||||
today = Time.zone.now |
collection_start_year(Time.zone.now) |
||||||
window_end_date = Time.zone.local(today.year, 4, 1) |
|
||||||
today < window_end_date ? today.year - 1 : today.year |
|
||||||
end |
end |
||||||
|
|
||||||
def collection_start_date(date) |
def collection_start_date(date) |
||||||
window_end_date = Time.zone.local(date.year, 4, 1) |
Time.zone.local(collection_start_year(date), 4, 1) |
||||||
date < window_end_date ? Time.zone.local(date.year - 1, 4, 1) : Time.zone.local(date.year, 4, 1) |
|
||||||
end |
end |
||||||
|
|
||||||
def current_collection_start_date |
def current_collection_start_date |
||||||
Time.zone.local(current_collection_start_year, 4, 1) |
Time.zone.local(current_collection_start_year, 4, 1) |
||||||
end |
end |
||||||
|
|
||||||
|
def collection_end_date(date) |
||||||
|
Time.zone.local(collection_start_year(date) + 1, 3, 31) |
||||||
|
end |
||||||
|
|
||||||
|
def current_collection_end_date |
||||||
|
Time.zone.local(current_collection_start_year + 1, 3, 31) |
||||||
|
end |
||||||
end |
end |
||||||
|
Loading…
Reference in new issue