diff options
author | Salvador Cuñat <salvador.cunat@gmail.com> | 2017-01-22 14:05:06 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2017-02-10 20:30:58 -0800 |
commit | f7045c57cd94700d64ef4e18b4733c9d8cab1e79 (patch) | |
tree | 3aad0c11e431ab88e174c9397892ac0f56c75f28 | |
parent | 7c91cdd89e4316c45b6fa1ea4830f4c2c879f773 (diff) | |
download | subsurface-f7045c57cd94700d64ef4e18b4733c9d8cab1e79.tar.gz |
smtk-import-improve smtk_time_to_secs()
Can't remember what I was thinking when wrote that crappy thing. A
simple sscanf call will do the job, and a sanity check, off course.
Signed-off-by: Salvador Cuñat <salvador.cunat@gmail.com>
-rw-r--r-- | smtk-import/smartrak.c | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/smtk-import/smartrak.c b/smtk-import/smartrak.c index e102c1abd..3fd8db6de 100644 --- a/smtk-import/smartrak.c +++ b/smtk-import/smartrak.c @@ -118,15 +118,11 @@ static void smtk_time_to_tm(char *t_buffer, struct tm *tm_date) */ static unsigned int smtk_time_to_secs(char *t_buffer) { - char *temp; - unsigned int hr, min, sec; + unsigned int n, hr, min, sec; if (!same_string(t_buffer, "")) { - temp = rindex(copy_string(t_buffer), ' '); - hr = atoi(strtok(temp, ":")); - min = atoi(strtok(NULL, ":")); - sec = atoi(strtok(NULL, "\0")); - return((((hr*60)+min)*60)+sec); + n = sscanf(t_buffer, "%*m[/0-9] %d:%d:%d ", &hr, &min, &sec); + return((n == 3) ? (((hr*60)+min)*60)+sec : 0); } else { return 0; } |