A simple widget that's capable of displaying time for multiple locations around the world. In our company(neo), we use it to display time in different offices.
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 default timezone configuration(shown below in world_clock.cofee) 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"></div>
</li>
@derrybarry https://gist.github.com/weilu/9613906
@Doc-Savage moment.js changed its interface.
moment.tz(new Date(), location.zone)
used to work but not anymore. I've updated it tomoment().tz(location.zone)
@intaker by default
application.coffee
does#= require_directory .
which does not guarantee the order things are required. By explicitly requiring the 3 different files the order is enforced.@unkyard0 thanks for catching the typo. Fixed =)