A simple widget that's capable of displaying time for multiple locations around the world. Useful for displaying time in different offices for a multinational company.
1. Download moment.js 2.5.1 from MomentJS,
2. Download moment-timezone.js 0.0.3 from Moment Timezone.
3. Build the timezone data for locations you are interested in: http://momentjs.com/timezone/data/ and save the data file as moment-timezone-data.js
. Note that for the timezone configuration shown below to work, you will need to include timezone data of Asia, America and Europe when building moment-timezone-data.js.
4. Put all the downloaded files in your /assets/javascripts
directory.
5. Include them in application.coffee
in the following order:
#= require moment.min
#= require moment-timezone.min
#= require moment-timezone-data
6. The files world_clock.coffee
, world_clock.html
and world_clock.scss
go in the /widget/world_clock
directory.
7. Last but not least, add the widget html to your dashboard:
<li data-row="1" data-col="1" data-sizex="4" data-sizey="1">
<div data-view="WorldClock" class="widget widget-world-clock" data-primary="SG" data-config='{"SG":"Asia/Singapore","JK":"Asia/Jakarta","SF":"America/Los_Angeles","NYC":"America/New_York","EDH":"Europe/London"}'></div>
</li>
If you'd like the clock to be inverted, just add the inverted
class ...
<div data-view="WorldClock" class="widget widget-world-clock inverted" data-primary="SG" data-config='{...}'></div>
You can change the start/end hours using data-hours-start
and data-hours-end
respectively ...
<div data-view="WorldClock" class="widget widget-world-clock" data-hours-start="6" data-hours-end="15" data-primary="SG" data-config='{...}'></div>