NetSurf
Functions
time.h File Reference

Interface to time operations. More...

#include <time.h>
Include dependency graph for time.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

int nsc_sntimet (char *str, size_t size, time_t *timep)
 Write the time in seconds since epoch to a buffer. More...
 
nserror nsc_snptimet (const char *str, size_t size, time_t *timep)
 Parse time in seconds since epoc. More...
 
nserror nsc_strntimet (const char *str, size_t size, time_t *timep)
 Converts a date string to a number of seconds since epoch. More...
 
const char * rfc1123_date (time_t t)
 Create an RFC 1123 compliant date string from a Unix timestamp. More...
 

Detailed Description

Interface to time operations.

Definition in file time.h.

Function Documentation

◆ nsc_snptimet()

nserror nsc_snptimet ( const char *  str,
size_t  size,
time_t *  timep 
)

Parse time in seconds since epoc.

This is provided as strptime is not generally portable.

Parameters
strThe source buffer.
sizeThe length of the source buffer.
timepPointer to result.
Returns
NSERROR_OK on success or error code on faliure.

Definition at line 147 of file time.c.

References NSERROR_BAD_PARAMETER, NSERROR_OK, and strtoll().

Referenced by fetch_file_setup(), fetch_resource_setup(), llcache_process_metadata(), and urldb_load().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ nsc_sntimet()

int nsc_sntimet ( char *  str,
size_t  size,
time_t *  timep 
)

Write the time in seconds since epoch to a buffer.

This is provided as strftime is not generally portable.

Parameters
strThe destination buffer.
sizeThe length of the destination buffer.
timepThe pointer to the time to write.
Returns
The length of the string written.

Definition at line 126 of file time.c.

Referenced by llcache_serialise_metadata(), and urldb_write_timet().

Here is the caller graph for this function:

◆ nsc_strntimet()

nserror nsc_strntimet ( const char *  str,
size_t  size,
time_t *  timep 
)

Converts a date string to a number of seconds since epoch.

returns the number of seconds since the Epoch, January 1st 1970 00:00:00 in the UTC time zone, for the date and time that the str parameter specifies.

datetime strings passed must be in one of the formats specified in:

  • RFC 822 (updated in RFC 1123) using time zone name or time zone delta
  • RFC 850 (obsoleted by RFC 1036)
  • ANSI C's asctime() format.
Parameters
[in]strThe datetime string to parse
[in]sizeThe length of the source string
[out]timepPointer to result on success unmodified on error.
Returns
NSERROR_OK on success and timep updated else NSERROR_INVALID if the string parsing failed otherwise a suitable error code

Definition at line 980 of file time.c.

References time__get_date().

Referenced by llcache_fetch_header_cache_control(), and urldb_parse_avpair().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ rfc1123_date()

const char * rfc1123_date ( time_t  t)

Create an RFC 1123 compliant date string from a Unix timestamp.

Parameters
tThe timestamp to consider
Returns
Pointer to buffer containing string - invalidated by next call.

Definition at line 110 of file time.c.

References months, and weekdays_short.

Referenced by llcache_object_refetch().

Here is the caller graph for this function: