Do not convert to Dates twice (#5563)

* Don't convert Dates twice

* Take string dates into account
This commit is contained in:
Nicolas Gotchac 2017-05-09 12:55:52 +02:00 committed by Jaco Greeff
parent df9096df80
commit 1288b4b28f

View File

@ -92,6 +92,16 @@ export function outChainStatus (status) {
}
export function outDate (date) {
if (typeof date.toISOString === 'function') {
return date;
}
try {
if (typeof date === 'string' && (new Date(date)).toISOString() === date) {
return new Date(date);
}
} catch (error) {}
return new Date(outNumber(date).toNumber() * 1000);
}