summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBartłomiej Wąs <b.was@infbud.pl>2017-01-25 21:31:51 +0100
committerBartłomiej Wąs <b.was@infbud.pl>2017-01-25 21:31:51 +0100
commite86f411dfcef958cf75103ad1eb0e133ba546dc3 (patch)
treed430134de659e06535da602215b79ebfefd596b0
parent46f60205a566dda7dbd8db0841a5c1b069361c24 (diff)
downloadlove2d-signage-e86f411dfcef958cf75103ad1eb0e133ba546dc3.tar.gz
love2d-signage-e86f411dfcef958cf75103ad1eb0e133ba546dc3.tar.bz2
love2d-signage-e86f411dfcef958cf75103ad1eb0e133ba546dc3.zip
Parametric date&time format i time.node
-rw-r--r--nodes/time.lua10
1 files changed, 8 insertions, 2 deletions
diff --git a/nodes/time.lua b/nodes/time.lua
index 7f8befc..1e0968b 100644
--- a/nodes/time.lua
+++ b/nodes/time.lua
@@ -3,6 +3,12 @@ local node = Node:extend('nodes.time', {})
local textFont = love.graphics.newFont('fonts/Lato-Thin.ttf', 400)
local smallFont = love.graphics.newFont('fonts/Lato-Light.ttf', 60)
+function node:init(config)
+ node.super.init(self, config)
+ self.timeFormat = self.timeFormat or '%H:%M'
+ self.dateFormat = self.dateFormat or '%Y/%m/%d'
+end
+
function node:render()
love.graphics.setColor( 0, 0, 0 )
love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), love.graphics.getHeight())
@@ -10,10 +16,10 @@ function node:render()
love.graphics.setColor( 255, 255, 255 )
love.graphics.setFont(textFont);
- love.graphics.printf(os.date('%H:%M'), 0, 0.14*love.graphics.getHeight(), love.graphics.getWidth(), 'center');
+ love.graphics.printf(os.date(self.timeFormat), 0, 0.14*love.graphics.getHeight(), love.graphics.getWidth(), 'center');
love.graphics.setFont(smallFont);
- love.graphics.printf(os.date('%Y/%m/%d'), 0, 0.8*love.graphics.getHeight(), love.graphics.getWidth(), 'center');
+ love.graphics.printf(os.date(self.dateFormat), 0, 0.8*love.graphics.getHeight(), love.graphics.getWidth(), 'center');
end
return node