From b29c35b91b550eb1e1668c1fd6312840de0eddd7 Mon Sep 17 00:00:00 2001 From: Anton Vakhrushev Date: Tue, 8 Oct 2019 16:57:36 +0300 Subject: [PATCH] Configure time zone --- Dockerfile | 2 +- src/expansion.cr | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index d97bbce..ac4ea2d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,3 @@ FROM alpine:edge as builder -RUN apk add -u crystal shards libc-dev +RUN apk add -u crystal shards tzdata libc-dev diff --git a/src/expansion.cr b/src/expansion.cr index 83bfece..45dedec 100644 --- a/src/expansion.cr +++ b/src/expansion.cr @@ -36,6 +36,11 @@ router.add "help", "Show all commands" do |p| end end +def render_time(ts) + t = Time.unix(ts).in(Time::Location.load("Europe/Moscow")) + t.to_s("%H:%M:%S") +end + def render_map(world) size = world.map.size (0...size).each do |x| @@ -80,9 +85,8 @@ def render_commands(world) if items.size != 0 printf "Queue:\n" end - time = ->(ts : Int64) { Time.unix(ts).to_local.to_s } items.each do |i| - printf " %s, %s\n", time.call(i.ts), i.command.desc + printf " %s, %s\n", render_time(i.ts), i.command.desc end end @@ -93,7 +97,7 @@ def render_resources(world) end def render_world(world) - printf "Now:\n %s\n\n", Time.unix(world.ts).to_local.to_s + printf "Now:\n %s\n\n", render_time(world.ts) if world.win? printf "YOU WIN!!!\n\n" end