Graphics.prototype.setFontSixCaps = function(scale) {
  // Actual height 60 (59 - 0)
  this.setFontCustom(atob("[encoded data, 7960 characters]"), 46, atob("CAwODQ4PDw8QDA8QCA=="), 69+(scale<<8)+(4<<16));
  return this;
};

const offset = 25;
const width = g.getWidth();
const height = g.getHeight();

var drawTimeout;
var fgTime = 0xf800;
var bgTime = 0x3333ff;
var dayDate = 0x000;

function queueDraw() {
  if (drawTimeout) clearTimeout(drawTimeout);
  drawTimeout = setTimeout(function() {
    drawTimeout = undefined;
    draw();
  }, 60000 - (Date.now() % 60000));
}

function time() {
  require("Font4x5").add(Graphics);
  var d = new Date();
  var day = d.getDate();
  var time = require("locale").time(d,1);
  //var date = require("locale").date(d);
  var mo = require("date_utils").month(d.getMonth()+1,0);

  g.setFontAlign(0,0);
  g.setFontSixCaps(2).setColor(fgTime).drawString(time, width/2, height/2+10);
  
  g.setFont("4x5",2);
  g.setFontAlign(0,0);
  g.setColor(dayDate).drawString(mo,width-55, height-16);
  g.drawString(day,width-10, height-16);
}

function draw() {
  g.setColor(bgTime).fillRect(0,40,width,height-offset);
  time();
  queueDraw();
}

//program start
g.clear(); // Clear the screen once, at startup

if (g.theme.dark==true){
  dayDate = 0xffff;
}
else {
  dayDate=0x000;
}

draw(); // draw immediately at first



// Show launcher when middle button pressed
Bangle.setUI("clock");
// Load widgets
Bangle.loadWidgets();
Bangle.drawWidgets();
