Spaces:
Running
Running
Merge pull request #36 from Topping1/master
Browse filesFix SRT timestamp format from mm:ss.sss to hh:mm:ss.sss
main.cpp
CHANGED
|
@@ -14,13 +14,16 @@
|
|
| 14 |
// 500 -> 00:05.000
|
| 15 |
// 6000 -> 01:00.000
|
| 16 |
std::string to_timestamp(int64_t t) {
|
| 17 |
-
int64_t
|
| 18 |
-
int64_t
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
|
|
|
|
|
|
|
|
|
| 22 |
char buf[32];
|
| 23 |
-
snprintf(buf, sizeof(buf), "%02d:%02d.%03d", (int) min, (int) sec, (int) msec);
|
| 24 |
|
| 25 |
return std::string(buf);
|
| 26 |
}
|
|
|
|
| 14 |
// 500 -> 00:05.000
|
| 15 |
// 6000 -> 01:00.000
|
| 16 |
std::string to_timestamp(int64_t t) {
|
| 17 |
+
int64_t msec = t * 10;
|
| 18 |
+
int64_t hr = msec / (1000 * 60 * 60);
|
| 19 |
+
msec = msec - hr * (1000 * 60 * 60);
|
| 20 |
+
int64_t min = msec / (1000 * 60);
|
| 21 |
+
msec = msec - min * (1000 * 60);
|
| 22 |
+
int64_t sec = msec / 1000;
|
| 23 |
+
msec = msec - sec * 1000;
|
| 24 |
+
|
| 25 |
char buf[32];
|
| 26 |
+
snprintf(buf, sizeof(buf), "%02d:%02d:%02d.%03d", (int) hr, (int) min, (int) sec, (int) msec);
|
| 27 |
|
| 28 |
return std::string(buf);
|
| 29 |
}
|