Commit 007fde03 by Anton Stupak

Merge pull request #3951 from edx/anton/fix-relative-time

RelativeTime: incorrect value after XML serialization.
parents fd18165b 865b6936
...@@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes, ...@@ -5,6 +5,8 @@ These are notable changes in edx-platform. This is a rolling list of changes,
in roughly chronological order, most recent first. Add your entries at or near in roughly chronological order, most recent first. Add your entries at or near
the top. Include a label indicating the component affected. the top. Include a label indicating the component affected.
Blades: Fix bug with incorrect RelativeTime value after XML serialization. BLD-1060
LMS: Update bulk email implementation to lessen load on the database LMS: Update bulk email implementation to lessen load on the database
by consolidating chunked queries for recipients into a single query. by consolidating chunked queries for recipients into a single query.
......
...@@ -3,6 +3,13 @@ ...@@ -3,6 +3,13 @@
describe('Time', function () { describe('Time', function () {
describe('format', function () { describe('format', function () {
describe('with NAN', function () {
it('return a correct time format', function () {
expect(Time.format('string')).toEqual('0:00');
expect(Time.format(void(0))).toEqual('0:00');
});
});
describe('with duration more than or equal to 1 hour', function () { describe('with duration more than or equal to 1 hour', function () {
it('return a correct time format', function () { it('return a correct time format', function () {
expect(Time.format(3600)).toEqual('1:00:00'); expect(Time.format(3600)).toEqual('1:00:00');
......
...@@ -12,6 +12,10 @@ ...@@ -12,6 +12,10 @@
function format(time, formatFull) { function format(time, formatFull) {
var hours, minutes, seconds; var hours, minutes, seconds;
if (!_.isFinite(time)) {
time = 0;
}
seconds = Math.floor(time); seconds = Math.floor(time);
minutes = Math.floor(seconds / 60); minutes = Math.floor(seconds / 60);
hours = Math.floor(minutes / 60); hours = Math.floor(minutes / 60);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment