Announcement

Collapse
No announcement yet.

EnumCalendarInfo and SYSTEMTIME

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bern Ertl
    replied
    Thanks.

    Leave a comment:


  • Egbert Zijlema
    replied
    Bern,

    Combined with my Greg.-library I use this (different values, but same idea, I guess):
    Code:
    %LOCALE_SDAYNAME1              = &H0000002A   ' long name for Monday
    %LOCALE_SDAYNAME2              = &H0000002B   ' long name for Tuesday
    %LOCALE_SDAYNAME3              = &H0000002C   ' long name for Wednesday
    %LOCALE_SDAYNAME4              = &H0000002D   ' long name for Thursday
    %LOCALE_SDAYNAME5              = &H0000002E   ' long name for Friday
    %LOCALE_SDAYNAME6              = &H0000002F   ' long name for Saturday
    %LOCALE_SDAYNAME7              = &H00000030   ' long name for Sunday
    This is my function:
    Code:
    ' ******************************************************************************
    ' * Function DayName - returns the locale-specific name of the day of the week *
    ' * parameters: wWeekDay: 1 = Monday ..... 7 = Sunday                          *
    ' *             dwLocale: country/language specific locale                     *
    ' *                       (defaults to %LOCALE_USER_DEFAULT if omitted or 0)   *
    ' *                                                                            *
    ' * NOTE: In Windows' SYSTEMTIME structure wDayOfWeek = 0 means Sunday         *
    ' *       This function now accepts both 0 and 7 as well for Sundays           *
    ' ******************************************************************************
    FUNCTION DayName(BYVAL wWeekDay AS WORD, OPTIONAL BYVAL dwLocale AS DWORD) AS STRING
      LOCAL szDayName AS ASCIIZ * 16, LCType AS LONG
    
      IF wWeekDay = 0 THEN wWeekday = 7                                 ' make function compatible with SYSTEMTIME's wDayOfWeek
      LCType = %LOCALE_SDAYNAME1 + wWeekDay - 1
      IF GetLocaleInfo(dwLocale, LCType, szDayName, SIZEOF(szDayName)) THEN
        FUNCTION = szDayName
      ELSE
        FUNCTION = ""
      END IF
    END FUNCTION
    Last edited by Egbert Zijlema; 3 Jun 2009, 04:10 AM.

    Leave a comment:


  • Bern Ertl
    replied
    Thanks Egbert. I found similar remarks in constant declarations for VB code on the internet, but I couldn't find anything in the MSDN documentation to confirm it. MSDN simply refers to the constants as representing "the ... day of the week". I guess I'll just run with it.

    Leave a comment:


  • Egbert Zijlema
    replied
    Hi Bern,

    As you might know, I prefer to use my own Gregorian Date routines for calendar/date issues. But this is what I find in WIN32API.INC:
    Code:
    %CAL_SDAYNAME1          = &H00000007  ' native name for Monday
    %CAL_SDAYNAME2          = &H00000008  ' native name for Tuesday
    %CAL_SDAYNAME3          = &H00000009  ' native name for Wednesday
    %CAL_SDAYNAME4          = &H0000000a  ' native name for Thursday
    %CAL_SDAYNAME5          = &H0000000b  ' native name for Friday
    %CAL_SDAYNAME6          = &H0000000c  ' native name for Saturday
    %CAL_SDAYNAME7          = &H0000000d  ' native name for Sunday
    Can this be considered as valid documentation?

    Regards
    Egbert

    Leave a comment:


  • Bern Ertl
    replied
    Just to clarify, I need to be able to map the day of week for a date returned from a SysDateTimePicker control (stored in a SYSTEMTIME function) to some data I've stored in an array with elements spanning %CAL_SDAYNAME1 to %CAL_SDAYNAME7.

    SYSTEMTIME (.wDayOfWeek) always uses 0 for Sunday. If EnumCalendarInfo is always using Monday for %CAL_SDAYNAME1 (offset 0), that would be fine as I could adjust the array index accordingly, but I can't seem to find any documentation stating whether that is true or not.

    Leave a comment:


  • Bern Ertl
    replied
    Well, I might have been wrong.

    I found that GetLocaleInfo with %LOCALE_IFIRSTDAYOFWEEK returns a number from 0 to 6, but when I'm testing on my computer with %LOCALE_SYSTEM_DEFAULT, it's returning 6 which corresponds to %CAL_SDAYNAME7 which returns Sunday.

    Does %CAL_SDAYNAME1 always correspond to Monday?

    Leave a comment:


  • Bern Ertl
    started a topic EnumCalendarInfo and SYSTEMTIME

    EnumCalendarInfo and SYSTEMTIME

    The wDayOfWeek element of the SYSTEMTIME structure always equates 0 with Sunday, 1 with Monday, etc.

    EnumCalendarInfo using %CAL_SDAYNAME1/%CAL_SABBREVDAYNAME1 could be Sunday, Monday or another day depending upon locale settings.

    How can I map the %CAL_SDAYNAME1 day to the correct wDayOfWeek value? Ie. is there an API function that lets me know which day of the week corresponds to %CAL_SDAYNAME1?
Working...
X