Remove Date hack, which was used for timeago

This commit is contained in:
Piotr Sarnacki 2013-03-06 14:43:13 +01:00
parent 754e6af17c
commit 8d9b36c0a6
4 changed files with 11 additions and 7 deletions

View File

@ -73,7 +73,7 @@ require 'config/emoij'
string
_nowUtc: ->
@_toUtc new Date()
@_toUtc Travis.currentDate()
_toUtc: (date) ->
Date.UTC date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds()

View File

@ -10,10 +10,10 @@ minispade.require 'app'
url = "/#{url}" unless url.match /^\//
Travis.__container__.lookup('router:main').handleURL(url)
_Date = Date
@Date = (date) ->
new _Date(date || '2012-07-02T00:03:00Z')
@Date.UTC = _Date.UTC
now = -> new Date('2012-07-02T00:03:00Z')
$.timeago.settings.nowFunction = -> now().getTime()
Travis.currentDate = now
# hacks for missing features in webkit
unless Function::bind

View File

@ -77,6 +77,9 @@ window.Travis = Em.Application.extend(Ember.Evented,
location.href = location.href.replace('#!/', '') if location.hash.slice(0, 2) == '#!'
I18n.fallbacks = true
@setLocale 'locale', @get('defaultLocale')
currentDate: ->
new Date()
).create()
Travis.deferReadiness()

View File

@ -41,7 +41,8 @@
months: '%d months',
year: 'about a year',
years: '%d years',
numbers: []
numbers: [],
nowFunction: function() { return new Date().getTime(); }
}
},
distanceInWords: function(date) {
@ -95,7 +96,7 @@
return (this.now() - date.getTime());
},
now: function() {
return new Date().getTime();
return this.settings.nowFunction.call(this);
},
parse: function(iso8601) {
var s = $.trim(iso8601);