mirror of
https://github.com/edeproject/ede.git
synced 2023-08-10 21:13:03 +03:00
Beggining of a function for date&time formatted output
This commit is contained in:
parent
69e1bd2de1
commit
56a568cc2c
@ -19,6 +19,7 @@
|
|||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
#include <time.h>
|
||||||
#include <fltk/filename.h>
|
#include <fltk/filename.h>
|
||||||
|
|
||||||
|
|
||||||
@ -223,6 +224,19 @@ const char* edelib::nice_size(double size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char* edelib::nice_time(long int epoch) {
|
||||||
|
static char buffer[256];
|
||||||
|
|
||||||
|
const time_t k = (const time_t)epoch;
|
||||||
|
const struct tm *timeptr = localtime(&k);
|
||||||
|
// Date/time format should be moved to configuration
|
||||||
|
snprintf(buffer,255,"%.2d.%.2d.%.4d. %.2d:%.2d", timeptr->tm_mday, timeptr->tm_mon, 1900+timeptr->tm_year, timeptr->tm_hour, timeptr->tm_min);
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Find in haystack any of needles (divided with separator)
|
// Find in haystack any of needles (divided with separator)
|
||||||
char* edelib::strstrmulti(const char *haystack, const char *needles, const char *separator) {
|
char* edelib::strstrmulti(const char *haystack, const char *needles, const char *separator) {
|
||||||
if (!haystack || !needles || (strlen(haystack)==0) || (strlen(needles)==0))
|
if (!haystack || !needles || (strlen(haystack)==0) || (strlen(needles)==0))
|
||||||
|
@ -62,6 +62,10 @@ char* strstrmulti(const char *haystack, const char *needles, const char *separat
|
|||||||
// Returns nicely formatted string for byte sizes e.g. "1.2 kB" for size=1284
|
// Returns nicely formatted string for byte sizes e.g. "1.2 kB" for size=1284
|
||||||
const char* nice_size(double size);
|
const char* nice_size(double size);
|
||||||
|
|
||||||
|
// Returns nicely formatted string for date and time given in seconds since
|
||||||
|
// Epoch. This should be in config
|
||||||
|
const char* nice_time(long int epoch);
|
||||||
|
|
||||||
// Create vector from string using separator
|
// Create vector from string using separator
|
||||||
//std::vector<char*> vec_from_string(const char *str, const char *separator);
|
//std::vector<char*> vec_from_string(const char *str, const char *separator);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user