diff options
author | Campbell Barton <ideasman42@gmail.com> | 2015-06-30 07:47:31 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2015-06-30 07:47:31 +0300 |
commit | 8bef305b6d6628d9d0cd9b8e8765108842fddc5b (patch) | |
tree | bb364cf7a6e7b1cffe6d3ae6dcd10584097b0354 /source/blender/blenlib/intern/timecode.c | |
parent | 56ca7f34dd602208880a41de6923fa71ebf83a29 (diff) |
Cleanup: move BLI_timestr to BLI_timecode
Diffstat (limited to 'source/blender/blenlib/intern/timecode.c')
-rw-r--r-- | source/blender/blenlib/intern/timecode.c | 30 |
1 files changed, 29 insertions, 1 deletions
diff --git a/source/blender/blenlib/intern/timecode.c b/source/blender/blenlib/intern/timecode.c index 39ffbcd7ebe..4ae9249ec0d 100644 --- a/source/blender/blenlib/intern/timecode.c +++ b/source/blender/blenlib/intern/timecode.c @@ -187,6 +187,34 @@ size_t BLI_timecode_string_from_time( return rlen; } +/** + * Generate time string and store in \a str + * + * \param str: destination string + * \param maxncpy: maximum number of characters to copy ``sizeof(str)`` + * \param time_seconds: time total time in seconds + * \return length of \a str + */ +size_t BLI_timecode_string_from_time_simple( + char *str, const size_t maxncpy, const double time_seconds) +{ + size_t rlen; + + /* format 00:00:00.00 (hr:min:sec) string has to be 12 long */ + const int hr = ( (int) time_seconds) / (60 * 60); + const int min = (((int) time_seconds) / 60 ) % 60; + const int sec = ( (int) time_seconds) % 60; + const int hun = ( (int) (time_seconds * 100.0)) % 100; + + if (hr) { + rlen = BLI_snprintf(str, maxncpy, "%.2d:%.2d:%.2d.%.2d", hr, min, sec, hun); + } + else { + rlen = BLI_snprintf(str, maxncpy, "%.2d:%.2d.%.2d", min, sec, hun); + } + + return rlen; +} /** * Generate time string and store in \a str @@ -200,7 +228,7 @@ size_t BLI_timecode_string_from_time( * * \note in some cases this is used to print non-seconds values. */ -size_t BLI_timecode_string_from_time_simple( +size_t BLI_timecode_string_from_time_seconds( char *str, const size_t maxncpy, const int power, const float time_seconds) { size_t rlen; |