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)
|
#define __STDC_WANT_LIB_EXT1__ 1
|
||||||
{
|
|
||||||
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 ";
|
|
||||||
}
|
|
||||||
|
|
||||||
void fsm_journal_publish (journal jj, char *message)
|
void fsm_journal_publish (journal jj, char *message)
|
||||||
{
|
{
|
||||||
unit *a_unit = jj.last;
|
unit *a_unit = jj.last;
|
||||||
char buf [JOURNAL_DATE_MAX_LENGTH];
|
char buf [JOURNAL_DATE_MAX_LENGTH];
|
||||||
char myString[] = "Hello World";
|
|
||||||
fsm_journal_get_event_date (myString);
|
|
||||||
|
|
||||||
int nb = 0;
|
int nb = 0;
|
||||||
while (a_unit)
|
while (a_unit)
|
||||||
{
|
{
|
||||||
// Format time, "ddd yyyy-mm-dd hh:mm:ss zzz" "%Y-%m-%d %H:%M:%S"
|
// 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://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));
|
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);
|
printf ("%s + %6ld %6d %s\n", buf, a_unit->usec, nb, a_unit->message);
|
||||||
a_unit = a_unit->prev;
|
a_unit = a_unit->prev;
|
||||||
nb ++;
|
nb ++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// char *event [JOURNAL_DATE_MAX_LENGTH] = "gyufgbyfjuvfde";
|
struct timeval tv;
|
||||||
// int **p_event [JOURNAL_DATE_MAX_LENGTH];
|
gettimeofday(&tv, NULL);
|
||||||
fsm_journal_get_event_date (message);
|
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) {
|
void modifyString(char *str) {
|
||||||
*str = ‘J‘; // Dereference to change first char
|
*str = ‘J‘; // Dereference to change first char
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int fonction_appelante() {
|
||||||
char myString[] = "Hello World";
|
char myString[] = "Hello World";
|
||||||
|
|
||||||
modifyString(myString);
|
modifyString(myString);
|
||||||
|
|
||||||
printf("%s", myString); // Prints Jello World
|
printf("%s", myString); // Prints Jello World
|
||||||
}
|
}
|
||||||
|
|
||||||
Because modifyString receives a pointer to the string,
|
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);
|
g_object_unref (app);
|
||||||
|
|
||||||
fsm_journal_publication_request ("main That'all folks ! 👋️😄️");
|
fsm_journal_publication_request ("main That'all folks ! 👋️😄️");
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue