diff options
| author | Konstantin <const@const.me> | 2023-02-03 19:01:04 +0100 |
|---|---|---|
| committer | Konstantin <const@const.me> | 2023-02-03 19:01:04 +0100 |
| commit | 3f3a9a156736d4da0339b3c2d9b042f4ed7c7fb2 (patch) | |
| tree | c3a4ba4291cb9fd6fae27d1e86c5ec26578aa6a2 /Examples/main/textWriter.cpp | |
| parent | 3ba8e6389679007445f4fc1c52439cb0df3ddba0 (diff) | |
Refactor, removed a redundant function
Diffstat (limited to 'Examples/main/textWriter.cpp')
| -rw-r--r-- | Examples/main/textWriter.cpp | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/Examples/main/textWriter.cpp b/Examples/main/textWriter.cpp index 6bb5ac4..6c37c1b 100644 --- a/Examples/main/textWriter.cpp +++ b/Examples/main/textWriter.cpp @@ -54,28 +54,19 @@ namespace return file.Write( bom.data(), 3 ); } - void printTime( CStringA& rdi, Whisper::sTimeSpan time, bool comma ) + void printTime( CStringA& rdi, Whisper::sTimeSpan time, bool comma = false ) { Whisper::sTimeSpanFields fields = time; + const uint32_t hours = fields.days * 24 + fields.hours; const char separator = comma ? ',' : '.'; rdi.AppendFormat( "%02d:%02d:%02d%c%03d", - (int)fields.hours, + (int)hours, (int)fields.minutes, (int)fields.seconds, separator, fields.ticks / 10'000 ); } - void printTimeStamp( CStringA& rdi, Whisper::sTimeSpan ts ) - { - Whisper::sTimeSpanFields fields = ts; - uint32_t msec = fields.ticks / 10'000; - uint32_t hr = fields.days * 24 + fields.hours; - uint32_t min = fields.minutes; - uint32_t sec = fields.seconds; - rdi.AppendFormat( "%02d:%02d:%02d.%03d", hr, min, sec, msec ); - } - const char* skipBlank( const char* rsi ) { while( true ) @@ -117,9 +108,9 @@ namespace if( timestamps ) { line = "["; - printTimeStamp( line, seg.time.begin ); + printTime( line, seg.time.begin ); line += " --> "; - printTimeStamp( line, seg.time.end ); + printTime( line, seg.time.end ); line += "] "; } else @@ -178,9 +169,9 @@ namespace const sSegment& seg = segments[ i ]; line = ""; - printTime( line, seg.time.begin, false ); + printTime( line, seg.time.begin ); line += " --> "; - printTime( line, seg.time.end, false ); + printTime( line, seg.time.end ); line += "\r\n"; line += skipBlank( seg.text ); line += "\r\n\r\n"; |
