Warning, file /multimedia/k3b/libk3b/videodvd/k3bvideodvdtime.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* 0002 SPDX-FileCopyrightText: 1998-2007 Sebastian Trueg <trueg@k3b.org> 0003 SPDX-License-Identifier: GPL-2.0-or-later 0004 */ 0005 0006 #include "k3bvideodvdtime.h" 0007 0008 K3b::VideoDVD::Time::Time() 0009 : m_hour(0), 0010 m_minute(0), 0011 m_second(0), 0012 m_frame(0) 0013 { 0014 } 0015 0016 0017 K3b::VideoDVD::Time::Time( unsigned short hour, 0018 unsigned short min, 0019 unsigned short sec, 0020 unsigned short frame, 0021 double frameRate ) 0022 : m_hour(hour), 0023 m_minute(min), 0024 m_second(sec), 0025 m_frame(frame), 0026 m_frameRate(frameRate) 0027 { 0028 // FIXME: how to handle the frames? 0029 m_minute += m_second/60; 0030 m_second = m_second % 60; 0031 m_hour += m_minute/60; 0032 m_minute = m_minute % 60; 0033 } 0034 0035 0036 double K3b::VideoDVD::Time::totalSeconds() const 0037 { 0038 double s = (double)second(); 0039 s += 60.0 * (double)minute(); 0040 s += 3600.0 * (double)hour(); 0041 0042 return s + double( frame() ) / frameRate(); 0043 } 0044 0045 0046 unsigned int K3b::VideoDVD::Time::totalFrames() const 0047 { 0048 double f = (double)second(); 0049 f += 60.0 * (double)minute(); 0050 f += 3600.0 * (double)hour(); 0051 0052 return unsigned( f * frameRate() ) + frame(); 0053 } 0054 0055 0056 QString K3b::VideoDVD::Time::toString( bool includeFrames ) const 0057 { 0058 if( includeFrames ) 0059 return QString::asprintf( "%02d:%02d:%02d.%02d", 0060 hour(), 0061 minute(), 0062 second(), 0063 frame() ); 0064 else 0065 return QString::asprintf( "%02d:%02d:%02d", 0066 hour(), 0067 minute(), 0068 second() + ( frame() > 0 ? 1 : 0 ) ); 0069 }