I looked in wxDateTime but found no solution.
How do I know if the first weekday is a Sunday or a Monday?
first weekday? Topic is solved
-
- Super wx Problem Solver
- Posts: 323
- Joined: Sun Jun 08, 2008 11:59 am
- Location: Bordeaux, France
Hello, hope it helps, i found this in cplusplus.com, but it is not related to wxWidgets. It is a plateforme undependent solution to get the day from the day (in number), the month and the year. C++ standard implies that the first day of the week is always Sunday....
Output:
Code: Select all
/* mktime example: weekday calculator */
#include <stdio.h>
#include <time.h>
int main ()
{
time_t rawtime;
struct tm * timeinfo;
int year, month ,day;
char * weekday[] = { "Sunday", "Monday",
"Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"};
/* prompt user for date */
printf ("Enter year: "); scanf ("%d",&year);
printf ("Enter month: "); scanf ("%d",&month);
printf ("Enter day: "); scanf ("%d",&day);
/* get current timeinfo and modify it to the user's choice */
time ( &rawtime );
timeinfo = localtime ( &rawtime );
timeinfo->tm_year = year - 1900;
timeinfo->tm_mon = month - 1;
timeinfo->tm_mday = day;
/* call mktime: timeinfo->tm_wday will be set */
mktime ( timeinfo );
printf ("That day is a %s.\n", weekday[timeinfo->tm_wday]);
return 0;
}
Enter year: 2000
Enter month: 5
Enter day: 20
That day is a Saturday.
OS: Ubuntu 11.10
Compiler: g++ 4.6.1 (Eclipse CDT Indigo)
wxWidgets: 2.9.3
Compiler: g++ 4.6.1 (Eclipse CDT Indigo)
wxWidgets: 2.9.3
-
- Super wx Problem Solver
- Posts: 323
- Joined: Sun Jun 08, 2008 11:59 am
- Location: Bordeaux, France
Sorry.
Trying to help (even to give a hint or an approach of the problem), is always a bad idea...
The next time I will close my mouth and will never try to answer questions....
Sorry for existing...
Hope "wx World domination" has what he wants....
Good bye.
Trying to help (even to give a hint or an approach of the problem), is always a bad idea...
The next time I will close my mouth and will never try to answer questions....
Sorry for existing...
Hope "wx World domination" has what he wants....
Good bye.
OS: Ubuntu 11.10
Compiler: g++ 4.6.1 (Eclipse CDT Indigo)
wxWidgets: 2.9.3
Compiler: g++ 4.6.1 (Eclipse CDT Indigo)
wxWidgets: 2.9.3