craft code to find a weekday name given a proleptic gregorian calendar date, without…
- User
craft code to find a weekday name given a proleptic gregorian calendar date, without using timestamps. *str weekday(in year,in month,int day) {
} test with str=weekday(2024,05,15); printf("%s", str); str=weekday(-2024,05,15); printf("%s", str); str=weekday(2021,05,15); printf("%s", str); str=weekday(-24,05,15); printf("%s", str); str = weekday(1985, 02, 12); printf("should be Tuesday:%s\n", str);
- Assistant
Here's a simple C function to find the weekday name given a proleptic Gregorian calendar date without using timestamps. This function uses Zeller's congruence, a widely used algorithm for calculating the day of the week.
c
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.