about summary refs log tree commit diff
path: root/src/base
diff options
context:
space:
mode:
Diffstat (limited to 'src/base')
-rw-r--r--src/base/system.c11
-rw-r--r--src/base/system.h13
2 files changed, 24 insertions, 0 deletions
diff --git a/src/base/system.c b/src/base/system.c
index 5799d972..bf0c6aa9 100644
--- a/src/base/system.c
+++ b/src/base/system.c
@@ -1280,6 +1280,17 @@ void str_hex(char *dst, int dst_size, const void *data, int data_size)
 	}
 }
 
+void str_timestamp(char *buffer, int buffer_size)
+{
+	time_t time_data;
+	struct tm *time_info;
+	
+	time(&time_data);
+	time_info = localtime(&time_data);
+	strftime(buffer, buffer_size, "%Y-%m-%d_%H-%M-%S", time_info);
+	buffer[buffer_size-1] = 0;	/* assure null termination */
+}
+
 int mem_comp(const void *a, const void *b, int size)
 {
 	return memcmp(a,b,size);
diff --git a/src/base/system.h b/src/base/system.h
index 39e7c994..2aca4de1 100644
--- a/src/base/system.h
+++ b/src/base/system.h
@@ -914,6 +914,19 @@ const char *str_find(const char *haystack, const char *needle);
 */
 void str_hex(char *dst, int dst_size, const void *data, int data_size);
 
+/*
+	Function: str_timestamp
+		Copies a time stamp in the format year-month-day_hour-minute-second to the string.
+
+	Parameters:
+		buffer - Pointer to a buffer that shall receive the time stamp string.
+		buffer_size - Size of the buffer.
+
+	Remarks:
+		- Guarantees that buffer string will contain zero-termination.
+*/
+void str_timestamp(char *buffer, int buffer_size);
+
 /* Group: Filesystem */
 
 /*