dcsimg
Results 1 to 7 of 7

Thread: What is the first day of the week?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jul 2017
    Posts
    126

    Question What is the first day of the week?

    Hello!

    I would like to find out what is set up as the "First Day of the Week" for a certain Windows system.

    I think when I pass vbUseSystemDayOfWeek to Weekday(), VB gets this setting somehow.

    I would like to ask how I could get to know it, too.

    Thank you!

    ps: The original reason for my question is the following:
    My application is multilingual. It contains a calendar. I can easily fill the weekday names using WeekdayName(Weekday()), etc.
    However, this only works for the current Windows language: The returned Weekday names are in the language of the OS.
    I would like to get the weekday names for other languages to. So I have to first find out which weekday a given date is.
    Since this depends on the First Day of the Week that is setup in Windows, I would have to retrieve this value something.

    Thank you!

  2. #2
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,406

    Re: What is the first day of the week?

    Monday is the first day of the week according to the international standard ISO 8601, but in the US, Canada, and Japan, it's counted as the second day of the week. Monday comes after Sunday and before Tuesday in our modern-day Gregorian Calendar.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jul 2017
    Posts
    126

    Re: What is the first day of the week?

    Yes, but I want to find out about this using a function. :-)

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jul 2017
    Posts
    126

    Re: What is the first day of the week?

    Do you know what I mean? The argument "vbUseSystemDayOfWeek" causes the function to look internally what the first day of the week is in the system.
    I would also like to know about this.

    How could I do this? I haven't found any API function that would tell me.

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Jul 2017
    Posts
    126

    Re: What is the first day of the week?

    I found a solution in C++:

    Code:
    int GetSystemStartDayOfWeek()
    {
        int   ret;
        DWORD StartDayOfWeek;
    
        ret = GetLocaleInfoEx(LOCALE_NAME_USER_DEFAULT,
            LOCALE_IFIRSTDAYOFWEEK | LOCALE_RETURN_NUMBER,
            (LPTSTR)&StartDayOfWeek,
            sizeof(StartDayOfWeek) / sizeof(TCHAR));
    
        return StartDayOfWeek;
    }

  6. #6
    PowerPoster
    Join Date
    Feb 2006
    Posts
    20,972

    Re: What is the first day of the week?

    There can theoretically be two values for each locale and user. There is the setting the system defaults to for the locale, and a possibly user-overridden effective value. If there has been an override than that is what normally gets used.

    I would not be surprised to find that some users go into the system settings and override various settings in order to make some half-baked program(s) work.

    As far as looking day names up you have to consider both the language and the region. In theory two German-speaking countries might use different names for Sunday. Locale ID values handle this by having a language and a sublanguage part.


    The demo attached contains calls to GetLocaleInfo(). You can pare it back to the minimum you need for a given program. I generally keep it intact as it is.
    Attached Files Attached Files

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Jul 2017
    Posts
    126

    Re: What is the first day of the week?

    Thank you so much!!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width