mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
7c91cdd89e
commit
f7045c57cd
1 changed files with 3 additions and 7 deletions
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue