Note: Not tested, but given the current year, this should do it:
const char *months[12]={"Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep",
"Oct","Nov","dec","Jan"};
/* Start with January 1st of the current year */
struct tm curYear={
0, // secs
0, // mins
0, // hours
1, // Day of month
0, // Month (Jan)
year,
0, // wday
0, // yday
0}; // isdst
/* Offset the number of weeks specified */
time_t secsSinceEpoch=mktime(&curYear)+
weekNum*86400*7; /* Shift by number of weeks */
struct tm *candidateDate=gmtime(&secsSinceEpoch);
/* If the candidate date is not a Monday, shift it so that it is */
if (candidateDate->tm_wday!=1)
{
secsSinceEpoch+=(86400*(candidateDate->tm_wday-1));
candidateDate=gmtime(&secsSinceEpoch);
}
printf("Mon %s %d",months[candidateDate->tm_mon],candidateDate->tm_mday\n");
You may have to adjust the formulas in this code depending on what exactly you mean by week 43 of a given year or to conform with ISO-8601, for example. However, this should present you with good boiler plate code to get started. You may also want to parameterize the day of the week, so that it is not hard coded.
Also, if you want, you can avoid the months array and having to format the time, by truncating the result of the ctime
function, which just so happens to display more than you asked for. You would pass to it a pointer to the secsSinceEpoch
value and truncate its output to just display the day of the week, the day of the month and the abbreviation of the months name.