Coverage Report

Created: 2026-02-26 06:20

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/ntp-dev/libntp/humandate.c
Line
Count
Source
1
/*
2
 * humandate.c - convert an NTP (or the current) time to something readable
3
 */
4
#include <config.h>
5
#include <stdio.h>
6
7
#include "ntp_fp.h"
8
#include "ntp_unixtime.h" /* includes <sys/time.h> and <time.h> */
9
#include "ntp_stdlib.h"
10
11
12
/* This is used in msyslog.c; we don't want to clutter up the log with
13
   the year and day of the week, etc.; just the minimal date and time.  */
14
15
const char *
16
humanlogtime(void)
17
0
{
18
0
  char *    bp;
19
0
  time_t    cursec;
20
0
  struct tm * tm;
21
  
22
0
  cursec = time(NULL);
23
0
  tm = localtime(&cursec);
24
0
  if (!tm)
25
0
    return "-- --- --:--:--";
26
27
0
  LIB_GETBUF(bp);
28
  
29
0
  snprintf(bp, LIB_BUFLENGTH, "%2d %s %02d:%02d:%02d",
30
0
     tm->tm_mday, months[tm->tm_mon],
31
0
     tm->tm_hour, tm->tm_min, tm->tm_sec);
32
    
33
0
  return bp;
34
0
}
35
36
37
/*
38
 * humantime() -- like humanlogtime() but without date, and with the
39
 *      time to display given as an argument.
40
 */
41
const char *
42
humantime(
43
  time_t cursec
44
  )
45
0
{
46
0
  char *    bp;
47
0
  struct tm * tm;
48
  
49
0
  tm = localtime(&cursec);
50
0
  if (!tm)
51
0
    return "--:--:--";
52
53
0
  LIB_GETBUF(bp);
54
  
55
0
  snprintf(bp, LIB_BUFLENGTH, "%02d:%02d:%02d",
56
0
     tm->tm_hour, tm->tm_min, tm->tm_sec);
57
    
58
0
  return bp;
59
0
}