JSTRFTIME(3)
β¨ JSTRFTIME(3) β¨
okay bestie, so this one is from the libjalali Manual and it's literally the jalali-flavored glow-up of strftime π
if you've ever wanted to format a Persian calendar date into a cute little string, this is the function that does it. no cap.
πΈ NAME πΈ
jstrftime β format jalali date and time ποΈβ¨
π SYNOPSIS π
#include <jtime.h>
size_t jstrftime(char *s, size_t max, const char *format,
const struct tm *jtm);
Link with -ljalali
π DESCRIPTION π
So jstrftime() takes your broken-down jalali time jtm and formats it according to the format spec format, then drops the result into the character array s which has size max. That's it, that's the whole vibe. π«Ά
The format spec is a null-terminated string and it can contain special character sequences called conversion specifications. Each one starts with a '%' character and ends with some other character, which we call a conversion specifier character. Everything else in there is just ordinary character sequences, no drama.
The characters of ordinary character sequences (including the null byte, yes even the null byte) get copied verbatim from format to s. But the characters of conversion specifications get replaced like this, and you're gonna want to memorize these fr fr:
%aβ the abbreviated weekday name.%Aβ the full weekday name.%bβ the abbreviated month name.%Bβ the full month name.%cβ the preferred date and time representation.%Cβ the century number (year/100) as a 2-digit integer.%dβ the day of the month as a decimal number (range 01 to 31).%Dβ equivalent to%Y/%m/%d.%eβ like%dthe day of the month as a decimal number, but a leading zero is replaced by a space. (SU)%Eβ the preferred date and time in Farsi. (utf8)%Fβ equivalent to%Y-%m-%d(similar to the ISO 8601 date format). (C99)%hβ the abbreviated Farsi transliterated weekday name.%qβ the full Farsi transliterated weekday name.%gβ the abbreviated Farsi weekday name. (utf8)%Gβ the full Farsi weekday name. (utf8)%vβ the abbreviated Farsi month name. (utf8)%Vβ the full Farsi month name. (utf8)%Hβ the hour as a decimal number using a 24-hour clock (range 00 to 23).%Iβ the hour as a decimal number using a 12-hour clock (range 01 to 12).%jβ the day of the year as a decimal number (range 001 to 366).%kβ the hour (24-hour clock) as a decimal number (range 0 to 23); single digits are preceded by a blank. (See also%H.) (TZ)%lβ the hour (12-hour clock) as a decimal number (range 1 to 12); single digits are preceded by a blank. (See also%I.) (TZ)%mβ the month as a decimal number (range 01 to 12).%Mβ the minute as a decimal number (range 00 to 59).%nβ a newline character. (SU)%Oβ AM or PM notation for the given time in Farsi equivalent. (utf8)%pβ either"AM"or"PM"according to the given time value. Noon is treated as"PM"and midnight as"AM".%Pβ like%pbut in lowercase:"am"or"pm"%rβ the time in a.m. or p.m. notation. In the POSIX locale this is equivalent to%I:%M:%S %p. (SU)%Rβ the time in 24-hour notation (%H:%M). (SU) For a version including the seconds, see%Tbelow.%sβ the number of seconds since the Epoch,1970-01-01(1348-10-11)00:00:00 +0000(UTC). (TZ)%Sβ the second as a decimal number (range 00 to 59).%tβ a tab character. (SU)%Tβ the time in 24-hour notation (%H:%M:%S). (SU)%uβ the day of the week as a decimal, range 1 to 7, Saturday being 1. See also%w. (SU)%Uβ the week number of the current year as a decimal number, range 00 to 53, starting with the first Sunday as the first day of week 01.%wβ the day of the week as a decimal, range 0 to 6, Saturday being 0. See also%u.%Wβ the preferred date in%Y/%m/%dformat and Farsi. (utf8)%xβ the preferred date representation without the time.%Xβ the preferred time representation without the date in Farsi. (utf8)%yβ the year as a decimal number without a century (range 00 to 99).%Yβ the year as a decimal number including the century.%zβ the+hhmmor-hhmmnumeric timezone (that is, the hour and minute offset from UTC). (SU)%Zβ the timezone or name or abbreviation.%%β a literal'%'character.
The broken-down time structure tm is defined in <jtime.h>. See also jctime(3). π¦
β RETURN VALUE β
jstrftime() returns the number of characters placed in the array s, not including the terminating null byte β as long as the string, including that terminating null byte, actually fits. π
Otherwise? It returns max, and the contents of the array is undefined. π so like, don't play with that.
π ENVIRONMENT π
The environment variables TZ and LC_TIME are used. π
β¨ CONFORMING TO β¨
C99.
π§ EXAMPLES π§
RFC 2822-compliant date format (with an English locale for %a and %b)
"%a, %d %b %Y %T %z"
RFC 822-compliant date format (with an English locale for %a and %b)
"%a, %d %b %y %T %z"
π Example Program π
The program below can be used to experiment with jstrftime(). obsessed honestly.
Some examples of the result string produced by the libjalali implementation of jstrftime() are as follows:
$ ./a.out '%m'
Result string is "11"
Here's the program source:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <jalali.h>
#include <jtime.h>
int
main(int argc, char *argv[])
{
char outstr[200];
time_t t;
struct tm *tmp;
t = time(NULL);
tmp = jlocaltime(&t);
if (tmp == NULL) {
perror("jlocaltime");
exit(EXIT_FAILURE);
}
if (jstrftime(outstr, sizeof(outstr), argv[1], tmp) == 0) {
fprintf(stderr, "jstrftime returned 0");
exit(EXIT_FAILURE);
}
printf("Result string is \"%s\"\n", outstr);
exit(EXIT_SUCCESS);
}
π SEE ALSO π
jdate(1), jcal(1), time(2), jctime(3), sprintf(3), jstrptime(3)
π COLOPHON π
This page is part of release 0.2 of the libjalali man-pages.
πΈ AUTHOR πΈ
Written by Ashkan Ghassemi. <ghassemi@ftml.net>
π REPORTING BUGS π
Report libjalali bugs to <ghassemi@ftml.net>
libjalali home page: <http://savannah.nongnu.org/projects/jcal/>
π COPYRIGHT π
Copyright (C) 2011 Ashkan Ghassemi.
License LGPLv3+: GNU LGPL version 3 or later <http://gnu.org/licenses/lgpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law.
and that's the whole page bestie!! π«Ά this one is from GNU, dated 2011-05-28, and it's the JSTRFTIME(3) page β go format something iconic with it. periodt. π β¨
π¦ where this page comes from
- debian trixie: jcal 0.5.1-0.2
- fedora 43: libjalali-devel 0.4.1-32.fc43 Β· GPL-3.0-or-later
- fedora 43: libjalali-devel 0.4.1-32.fc43 Β· GPL-3.0-or-later
- fedora 44: libjalali-devel 0.4.1-33.fc44 Β· GPL-3.0-or-later
- fedora 44: libjalali-devel 0.4.1-33.fc44 Β· GPL-3.0-or-later
- nixos 26.05: jcal 0.5.1
- nixpkgs unstable: jcal 0.5.1
- ubuntu questing: jcal 0.5.1-0.2
- ubuntu resolute: jcal 0.5.1-0.2build1
- ubuntu stonking: jcal 0.5.1-0.2build1
- Copyright (C) 2006, 2007, 2009, 2010, 2011 Ashkan Ghassemi
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms