Fixed issue#478 - Token without expiration timestamp expires "01/01/1970”.

This commit is contained in:
Martin Edenhofer 2016-11-29 21:54:49 +01:00
parent e0b70cb24f
commit 53440fbbdd
2 changed files with 44 additions and 0 deletions

View file

@ -288,9 +288,11 @@ class _i18nSingleton extends Spine.Module
@_notTranslated[locale][key] = true @_notTranslated[locale][key] = true
date: (time, offset) => date: (time, offset) =>
return time if !time
@convert(time, offset, @mapTime['date'] || @dateFormat) @convert(time, offset, @mapTime['date'] || @dateFormat)
timestamp: (time, offset) => timestamp: (time, offset) =>
return time if !time
@convert(time, offset, @mapTime['timestamp'] || @timestampFormat) @convert(time, offset, @mapTime['timestamp'] || @timestampFormat)
convert: (time, offset, format) -> convert: (time, offset, format) ->

View file

@ -312,6 +312,27 @@ test('i18n', function() {
var timestamp = App.i18n.translateTimestamp('2012-11-06T21:07:24Z', offset); var timestamp = App.i18n.translateTimestamp('2012-11-06T21:07:24Z', offset);
equal(timestamp, '06.11.2012 21:07', 'de-de - timestamp translated correctly') equal(timestamp, '06.11.2012 21:07', 'de-de - timestamp translated correctly')
timestamp = App.i18n.translateTimestamp('', offset);
equal(timestamp, '', 'de-de - timestamp translated correctly')
timestamp = App.i18n.translateTimestamp(null, offset);
equal(timestamp, null, 'de-de - timestamp translated correctly')
timestamp = App.i18n.translateTimestamp(undefined, offset);
equal(timestamp, undefined, 'de-de - timestamp translated correctly')
var date = App.i18n.translateDate('2012-11-06', 0)
equal(date, '06.11.2012', 'de-de - date translated correctly')
date = App.i18n.translateDate('', 0)
equal(date, '', 'de-de - date translated correctly')
date = App.i18n.translateDate(null, 0)
equal(date, null, 'de-de - date translated correctly')
date = App.i18n.translateDate(undefined, 0)
equal(date, undefined, 'de-de - date translated correctly')
// en // en
App.i18n.set('en-us') App.i18n.set('en-us')
translated = App.i18n.translateContent('yes') translated = App.i18n.translateContent('yes')
@ -368,6 +389,27 @@ test('i18n', function() {
timestamp = App.i18n.translateTimestamp('2012-11-06T21:07:24Z', offset) timestamp = App.i18n.translateTimestamp('2012-11-06T21:07:24Z', offset)
equal(timestamp, '11/06/2012 21:07', 'en - timestamp translated correctly') equal(timestamp, '11/06/2012 21:07', 'en - timestamp translated correctly')
timestamp = App.i18n.translateTimestamp('', offset);
equal(timestamp, '', 'en - timestamp translated correctly')
timestamp = App.i18n.translateTimestamp(null, offset);
equal(timestamp, null, 'en - timestamp translated correctly')
timestamp = App.i18n.translateTimestamp(undefined, offset);
equal(timestamp, undefined, 'en - timestamp translated correctly')
date = App.i18n.translateDate('2012-11-06', 0)
equal(date, '11/06/2012', 'en - date translated correctly')
date = App.i18n.translateDate('', 0)
equal(date, '', 'en - date translated correctly')
date = App.i18n.translateDate(null, 0)
equal(date, null, 'en - date translated correctly')
date = App.i18n.translateDate(undefined, 0)
equal(date, undefined, 'en - date translated correctly')
// locale alias test // locale alias test
// de // de
App.i18n.set('de') App.i18n.set('de')