I was wrong in my first post, and ICU provides a C API.
So, if dependency on that library is acceptable for you, you can get the first of the week portably using the following snippet:
#include <stdio.h>
/* for calendar functions */
#include <unicode/ucal.h>
/* for u_cleanup() */
#include <unicode/uclean.h>
/* for uloc_getDefault() */
#include <unicode/uloc.h>
int main()
{
/* it *has* to be pre-set */
UErrorCode err = U_ZERO_ERROR;
UCalendar* cal = ucal_open(
0, -1, /* default timezone */
uloc_getDefault(), /* default (current) locale */
UCAL_DEFAULT, /* default calendar type */
&err);
if (!cal)
{
fprintf(stderr, "ICU error: %s\n", u_errorName(err));
u_cleanup();
return 1;
}
/* 1 for sunday, 2 for monday, etc. */
printf("%d\n", ucal_getAttribute(cal, UCAL_FIRST_DAY_OF_WEEK));
ucal_close(cal);
u_cleanup();
return 0;
}
Then you link the program with icu-i18n
pkg-config library.
Ah, and they have quite an extensive example printing a calendar, if you might be interested.