Skip to content

Commit

Permalink
Fix incorrect duration calculation in demo app.
Browse files Browse the repository at this point in the history
Demo app used Date for convert total seconds to hours, minutes and seconds.
It set Date in UTC format but read in local time zone.
As result localtime zone hours count added to output.
  • Loading branch information
tarhan authored and cookpete committed Dec 6, 2016
1 parent b6f5293 commit 4114677
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/demo/Duration.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ export default function Duration ({ className, seconds }) {

function format (seconds) {
const date = new Date(seconds * 1000)
const hh = date.getHours()
const mm = date.getMinutes()
const ss = pad(date.getSeconds())
const hh = date.getUTCHours()
const mm = date.getUTCMinutes()
const ss = pad(date.getUTCSeconds())
if (hh) {
return `${hh}:${pad(mm)}:${ss}`
}
Expand Down

1 comment on commit 4114677

@MekkerKata
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm working on a webapp project, and have this file in my library.
But on Android its not working properly. Instead of give back ex. 1:45:33 its giving 0:27.
Any idea why?

Please sign in to comment.