Page 1 of 1

first weekday?

Posted: Sun Sep 06, 2009 3:51 pm
by MoonKid
I looked in wxDateTime but found no solution.

How do I know if the first weekday is a Sunday or a Monday?

Posted: Tue Sep 08, 2009 4:20 pm
by tierra
This is typically a locale setting, but wxWidgets' locale support is very limited, and doesn't actually provide any cross-platform approach for finding it.

This needs to be done with platform-specific code. You would need to look up how to do this yourself.

Posted: Tue Sep 08, 2009 4:36 pm
by Muetdhiver
Hello, hope it helps, i found this in, 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....

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.

Posted: Wed Sep 09, 2009 4:10 pm
by tierra
That's not what he's asking...

Posted: Thu Sep 10, 2009 8:20 am
by Muetdhiver
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.