WIP: strftime again
This commit is contained in:
parent
70c932170a
commit
23724de26e
|
@ -125,61 +125,48 @@ void fsm_journal_seek (journal jj, long usec, char *message)
|
|||
|
||||
//------------------------------------------------------------------------------------
|
||||
|
||||
static void fsm_journal_get_event_date (char *event)
|
||||
{
|
||||
struct timeval tv;
|
||||
gettimeofday (&tv, NULL);
|
||||
long yy_dd_mm = tv.tv_sec;
|
||||
long usec = tv.tv_usec;
|
||||
|
||||
char buf1[]="";
|
||||
strftime (buf1, JOURNAL_DATE_MAX_LENGTH, "%D %T", localtime (&yy_dd_mm));
|
||||
printf ("%s + %6ld ", buf1, usec);
|
||||
|
||||
// *event = "ldkvbhej xadrhsjfvrejhs ";
|
||||
}
|
||||
#define __STDC_WANT_LIB_EXT1__ 1
|
||||
|
||||
void fsm_journal_publish (journal jj, char *message)
|
||||
{
|
||||
unit *a_unit = jj.last;
|
||||
char buf [JOURNAL_DATE_MAX_LENGTH];
|
||||
char myString[] = "Hello World";
|
||||
fsm_journal_get_event_date (myString);
|
||||
|
||||
int nb = 0;
|
||||
while (a_unit)
|
||||
{
|
||||
// Format time, "ddd yyyy-mm-dd hh:mm:ss zzz" "%Y-%m-%d %H:%M:%S"
|
||||
// https://www.man7.org/linux/man-pages/man3/strftime.3.html
|
||||
// https://en.cppreference.com/w/c/io/fprintf
|
||||
// https://nicolasj.developpez.com/articles/libc/string/
|
||||
// https://thelinuxcode.com/pass-string-function-c-language/
|
||||
strftime(buf, sizeof(buf), "%D %T", localtime(&a_unit->yy_dd_mm));
|
||||
printf ("%s + %6ld %6d %s\n", buf, a_unit->usec, nb, a_unit->message);
|
||||
a_unit = a_unit->prev;
|
||||
nb ++;
|
||||
}
|
||||
|
||||
// char *event [JOURNAL_DATE_MAX_LENGTH] = "gyufgbyfjuvfde";
|
||||
// int **p_event [JOURNAL_DATE_MAX_LENGTH];
|
||||
fsm_journal_get_event_date (message);
|
||||
struct timeval tv;
|
||||
gettimeofday(&tv, NULL);
|
||||
long yy_dd_mm = tv.tv_sec;
|
||||
// long usec = tv.tv_usec; << how to use if (format)
|
||||
|
||||
printf ("%4d %s\n", nb, message);
|
||||
strftime(buf, sizeof(buf), "%D %T", localtime(&yy_dd_mm));
|
||||
|
||||
printf ("%s + %6d %s\n", buf, nb, message);
|
||||
}
|
||||
|
||||
// https://nicolasj.developpez.com/articles/libc/string/
|
||||
// https://thelinuxcode.com/pass-string-function-c-language/
|
||||
//
|
||||
/*
|
||||
void modifyString(char *str) {
|
||||
*str = ‘J‘; // Dereference to change first char
|
||||
}
|
||||
|
||||
int main() {
|
||||
int fonction_appelante() {
|
||||
char myString[] = "Hello World";
|
||||
|
||||
modifyString(myString);
|
||||
|
||||
printf("%s", myString); // Prints Jello World
|
||||
}
|
||||
|
||||
Because modifyString receives a pointer to the string,
|
||||
* it can modify the original by dereferencing.
|
||||
it can modify the original by dereferencing.
|
||||
*/
|
||||
|
|
|
@ -146,7 +146,6 @@ int main (int argc, char **argv)
|
|||
g_object_unref (app);
|
||||
|
||||
fsm_journal_publication_request ("main That'all folks ! 👋️😄️");
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue