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 string
_nowUtc: -> _nowUtc: ->
@_toUtc new Date() @_toUtc Travis.currentDate()
_toUtc: (date) -> _toUtc: (date) ->
Date.UTC date.getFullYear(), date.getMonth(), date.getDate(), date.getHours(), date.getMinutes(), date.getSeconds(), date.getMilliseconds() 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 /^\// url = "/#{url}" unless url.match /^\//
Travis.__container__.lookup('router:main').handleURL(url) Travis.__container__.lookup('router:main').handleURL(url)
_Date = Date
@Date = (date) -> now = -> new Date('2012-07-02T00:03:00Z')
new _Date(date || '2012-07-02T00:03:00Z') $.timeago.settings.nowFunction = -> now().getTime()
@Date.UTC = _Date.UTC Travis.currentDate = now
# hacks for missing features in webkit # hacks for missing features in webkit
unless Function::bind 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) == '#!' location.href = location.href.replace('#!/', '') if location.hash.slice(0, 2) == '#!'
I18n.fallbacks = true I18n.fallbacks = true
@setLocale 'locale', @get('defaultLocale') @setLocale 'locale', @get('defaultLocale')
currentDate: ->
new Date()
).create() ).create()
Travis.deferReadiness() Travis.deferReadiness()

View File

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