Last active
December 13, 2015 17:18
-
-
Save cpuguy83/4946806 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ServiceLocalTime = | |
time_calc: (selector) -> | |
date = new Date() | |
local_offset = date.getTimezoneOffset() * 60000 | |
utc = date.getTime() + local_offset | |
offset = parseInt(selector.attr('data-tz-offset')) | |
time = utc + offset | |
new_date = new Date(time) | |
update_time: (time_element = $('span#service_local_time')) -> | |
time = @time_calc(time_element) | |
time_element.html("Local Time: #{time.toLocaleTimeString()}") | |
setTimeout ServiceLocalTime.update_time(time_element), 1000 | |
$(document).ready -> ServiceLocalTime.update_time() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@ServiceLocalTime = | |
time_calc: (offset) -> | |
date = new Date() | |
local_offset = date.getTimezoneOffset() * 60000 | |
utc = date.getTime() + local_offset | |
offset = parseInt(offset) | |
time = utc + offset | |
new_date = new Date(time) | |
update_time: (time_selector) -> | |
time_element = $(time_selector) | |
offset = parseInt(time_element.attr('data-tz-offset')) | |
time = @time_calc(offset) | |
time_element.html("Local Time: #{time.toLocaleTimeString()}") | |
$(document).ready -> | |
setInterval (=>ServiceLocalTime.update_time('span#service_local_time')), 1000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment