]> git.sesse.net Git - kdenlive/blob - src/gentime.cpp
Fix label
[kdenlive] / src / gentime.cpp
1 /***************************************************************************
2                           time.cpp  -  description
3                              -------------------
4     begin                : Sat Sep 14 2002
5     copyright            : (C) 2002 by Jason Wood
6     email                : jasonwood@blueyonder.co.uk
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
11  *   This program is free software; you can redistribute it and/or modify  *
12  *   it under the terms of the GNU General Public License as published by  *
13  *   the Free Software Foundation; either version 2 of the License, or     *
14  *   (at your option) any later version.                                   *
15  *                                                                         *
16  ***************************************************************************/
17
18 #include "gentime.h"
19
20 double GenTime::s_delta = 0.00001;
21
22 GenTime::GenTime()
23 {
24     m_time = 0.0;
25 }
26
27 GenTime::GenTime(double seconds)
28 {
29     m_time = seconds;
30 }
31
32 GenTime::GenTime(int frames, double framesPerSecond)
33 {
34     m_time = (double) frames / framesPerSecond;
35 }
36
37 double GenTime::seconds() const
38 {
39     return m_time;
40 }
41
42 double GenTime::ms() const
43 {
44     return m_time * 1000;
45 }
46
47 double GenTime::frames(double framesPerSecond) const
48 {
49     return floor(m_time * framesPerSecond + 0.5);
50 }
51
52 GenTime& GenTime::roundNearestFrame(double framesPerSecond)
53 {
54     m_time = floor((m_time * framesPerSecond) + 0.5) / framesPerSecond;
55     return *this;
56 }
57
58 QString GenTime::toString() const
59 {
60     return QString("%1 s").arg(m_time, 0, 'f', 2);
61 }