I have a function like this:
void ft_display_time(struct timespec ttime)
{
char *time_long;
time_long = ctime(&ttime.tv_sec);
if (time_long)
{
ft_printf("%.3s ", time_long + 4);
ft_printf("%.2s ", time_long + 8);
ft_printf("%.5s ", time_long + 11);
}
else
ft_putstr(" ");
}
I'm trying get an output like ls -l
does. But ctime(const time_t *clock)
will return a string in english (so months are displayed like "Dec" "Jan" "Aug" ...), while ls -l
outputs months in the host language format (for example french).
Example:
./myprog --long file
-rw-r--r-- 1 lotolo staff 0 Sep 17 19:55 c
/bin/ls -l
-rw-r--r-- 1 lotolo staff 0 17 Set 19:55 c
How could I have the output in host language format?
For instance, ttime
is equal to stat.st_atimespec
or stat.st_mtimespec
returned by stat(filename, &stat)
or lstat(filename, &stat)
I know I will have to change most of my ft_display_time()
funtion, but I would like to know if there is any way of getting ctime()
output in the right language.