LCOV - code coverage report
Current view: top level - src - time.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 20 20 100.0 %
Date: 2026-08-20 23:47:58 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 10 10 100.0 %

           Branch data     Line data    Source code
       1                 :            : // Copyright 2019-2026 David Robillard <d@drobilla.net>
       2                 :            : // SPDX-License-Identifier: ISC
       3                 :            : 
       4                 :            : #include "time.h"
       5                 :            : #include "date_time.h"
       6                 :            : #include "read_utils.h"
       7                 :            : #include "result.h"
       8                 :            : #include "time_utils.h"
       9                 :            : #include "write_utils.h"
      10                 :            : 
      11                 :            : #include <exess/exess.h>
      12                 :            : 
      13                 :            : #include <string.h>
      14                 :            : 
      15                 :            : EXESS_NONBLOCKING ExessOrder
      16                 :         96 : exess_compare_time(const ExessTime lhs, const ExessTime rhs)
      17                 :            : {
      18                 :         96 :   const ExessDateTime lhs_datetime = {
      19                 :         96 :     1972, 12U, 31U, lhs.zone, lhs.hour, lhs.minute, lhs.second, lhs.nanosecond};
      20                 :            : 
      21                 :         96 :   const ExessDateTime rhs_datetime = {
      22                 :         96 :     1972, 12U, 31U, rhs.zone, rhs.hour, rhs.minute, rhs.second, rhs.nanosecond};
      23                 :            : 
      24                 :         96 :   return exess_compare_date_time(lhs_datetime, rhs_datetime);
      25                 :            : }
      26                 :            : 
      27                 :            : EXESS_NONBLOCKING ExessResult
      28                 :       6052 : exess_read_time(const char* const str, ExessTime* const out)
      29                 :            : {
      30                 :       6052 :   memset(out, 0, sizeof(*out));
      31                 :            : 
      32                 :       6052 :   size_t      i = skip_whitespace(str);
      33                 :       6052 :   ExessResult r = read_time(out, str + i);
      34                 :            : 
      35         [ +  + ]:       6052 :   if (out->hour == 24) {
      36   [ +  +  +  +  :         11 :     if (out->minute || out->second || out->nanosecond) {
                   +  + ]
      37                 :          4 :       r.status = EXESS_OUT_OF_RANGE;
      38                 :            :     } else {
      39                 :          7 :       out->hour = 0;
      40                 :            :     }
      41                 :            :   }
      42                 :            : 
      43                 :       6052 :   r.count += i;
      44                 :       6052 :   return r;
      45                 :            : }
      46                 :            : 
      47                 :            : EXESS_NONBLOCKING ExessResult
      48                 :       5929 : exess_write_time(const ExessTime value, const size_t buf_size, char* const buf)
      49                 :            : {
      50                 :       5929 :   return (value.hour == 24)
      51                 :          4 :            ? end_write(EXESS_BAD_VALUE, buf_size, buf, 0)
      52         [ +  + ]:       5929 :            : write_time(value, buf_size, buf, RESULT(EXESS_SUCCESS, 0));
      53                 :            : }

Generated by: LCOV version 1.16