mirror of
https://github.com/zammad/zammad
synced 2026-05-24 09:48:36 +00:00
24 lines
487 B
Ruby
24 lines
487 B
Ruby
# Copyright (C) 2012-2026 Zammad Foundation, https://zammad-foundation.org/
|
|
|
|
class TimeRangeHelper
|
|
def self.relative(from: Time.zone.now, range: 'day', value: 1)
|
|
value = value.to_i
|
|
|
|
case range
|
|
when 'day'
|
|
from += value.days
|
|
when 'minute'
|
|
from += value.minutes
|
|
when 'hour'
|
|
from += value.hours
|
|
when 'week'
|
|
from += value.weeks
|
|
when 'month'
|
|
from += value.months
|
|
when 'year'
|
|
from += value.years
|
|
end
|
|
|
|
from
|
|
end
|
|
end
|