Sha256: 349c37ef402a357e7c10d3f4f54383e7d6466a371d089c6ace965d2f0384db29
Contents?: true
Size: 842 Bytes
Versions: 11
Compression:
Stored size: 842 Bytes
Contents
# frozen_string_literal: true require 'time' require 'active_support/core_ext/numeric/time' module Dsu module Support # This module provides functions for formatting Time objects # to display in the console. module TimeFormatable module_function def formatted_time(time:) time = time.localtime if time.utc? today_yesterday_or_tomorrow = if time.today? 'Today' elsif time.yesterday? 'Yesterday' elsif time.tomorrow? 'Tomorrow' end time_zone = timezone_for(time: time) return time.strftime("%A, %Y-%m-%d #{time_zone}") unless today_yesterday_or_tomorrow time.strftime("%A, (#{today_yesterday_or_tomorrow}) %Y-%m-%d #{time_zone}") end def timezone_for(time:) time.zone end end end end
Version data entries
11 entries across 11 versions & 1 rubygems