diff --git a/src/time/format/formatter.cr b/src/time/format/formatter.cr index 5639ca83c0cb..2d5e5eda0878 100644 --- a/src/time/format/formatter.cr +++ b/src/time/format/formatter.cr @@ -160,7 +160,7 @@ struct Time::Format io << time.day_of_week.value end - def epoch + def unix_time io << time.to_unix end diff --git a/src/time/format/parser.cr b/src/time/format/parser.cr index 091e57b18a3b..4136199238b9 100644 --- a/src/time/format/parser.cr +++ b/src/time/format/parser.cr @@ -17,7 +17,7 @@ struct Time::Format "PDT" => Location.fixed("PDT", -7 * 3600), } - @epoch : Int64? + @unix_seconds : Int64? @location : Location? def initialize(string) @@ -36,8 +36,8 @@ struct Time::Format def time(location : Location? = nil) @hour += 12 if @pm - if epoch = @epoch - return Time.unix(epoch) + if unix_seconds = @unix_seconds + return Time.unix(unix_seconds) end location = @location || location @@ -268,17 +268,17 @@ struct Time::Format consume_number(1) end - def epoch - epoch_negative = false + def unix_seconds + negative = false case current_char when '-' - epoch_negative = true + negative = true next_char when '+' next_char end - @epoch = consume_number_i64(19) * (epoch_negative ? -1 : 1) + @unix_seconds = consume_number_i64(19) * (negative ? -1 : 1) end def time_zone(with_seconds = false) diff --git a/src/time/format/pattern.cr b/src/time/format/pattern.cr index 46e2b45130dc..9b96d6ec7d6d 100644 --- a/src/time/format/pattern.cr +++ b/src/time/format/pattern.cr @@ -61,7 +61,7 @@ struct Time::Format when 'R' twenty_four_hour_time when 's' - epoch + unix_seconds when 'S' second when 'T', 'X'