Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ stamp-h1
/libutils/regex.h
/libutils/glob_lib.h
/libutils/json-yaml.h
/libutils/parsedate.c

# examples
/examples/cfengine_stdlib.cf
Expand Down
1 change: 1 addition & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ AC_PROG_CC
AC_PROG_MKDIR_P
AC_EXEEXT

AM_CONDITIONAL([DARWIN], [AS_CASE([$target_os], [darwin*], [true], [false])])
AS_CASE([${target_os}],
[darwin*], [
AC_CHECK_PROG([BREW], [brew], [brew])
Expand Down
8 changes: 7 additions & 1 deletion libutils/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ noinst_LTLIBRARIES = libutils.la
AM_CFLAGS = $(CORE_CFLAGS) $(PCRE2_CFLAGS) $(OPENSSL_CFLAGS)
AM_CPPFLAGS = $(CORE_CPPFLAGS) $(PCRE2_CPPFLAGS) $(OPENSSL_CPPFLAGS)
AM_LDFLAGS = $(CORE_LDFLAGS) $(PCRE2_LDFLAGS) $(OPENSSL_LDFLAGS)
if DARWIN
AM_YFLAGS = -d -p parsedate_yy
else
AM_YFLAGS = -d -p parsedate_yy -Wno-deprecated
endif

libutils_la_LIBADD = ../libcompat/libcompat.la $(PCRE2_LIBS) $(OPENSSL_LIBS) $(SYSTEMD_LOGGING_LIBS) $(LIBYAML_LIBS)

Expand Down Expand Up @@ -81,7 +86,8 @@ libutils_la_SOURCES = \
version_comparison.c version_comparison.h \
writer.c writer.h \
xml_writer.c xml_writer.h \
glob_lib.c glob_lib.h
glob_lib.c glob_lib.h \
parsedate.y parsedate.h

EXTRA_DIST = stack_base.c

Expand Down
16 changes: 16 additions & 0 deletions libutils/parsedate.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#ifndef PARSEDATE_H
#define PARSEDATE_H

#include <time.h>

/**
* Parses a date/time string into a time_t epoch timestamp.
*
* @param p The string buffer containing the date/time to parse.
* @param now Optional pointer to a reference time (pass NULL for current time).
* @param zone Optional pointer to a timezone offset in minutes (pass NULL for local time).
* @return Epoch timestamp (time_t), or (time_t)-1 on error.
*/
time_t ParseDate(const char *p, const time_t *now, const int *zone);

#endif /* PARSEDATE_H */
Loading
Loading