flat assembler
Message board for the users of flat assembler.

Index > Windows > How to fill day of week array

Author
Thread Post new topic Reply to topic
ATV



Joined: 31 Aug 2004
Posts: 109
Location: Finland
ATV 26 Jul 2007, 07:22
Is there easy way to get list of day_of_week in short format from user settings.
I am adding weekday names in my alarm program http://board.flatassembler.net/topic.php?t=5086

One easy way would be read them in ini file and overwrite 4*7 bytes array, but Im trying to do it automaticly.
Code:
  weekdays4        db 'Mon Tue Wed Thu Fri Sat Sun ',0

;in ini file with dummy x
weekdays4=Ma  Ti  Ke  To  Pe  La  Su  x
    
Post 26 Jul 2007, 07:22
View user's profile Send private message Reply with quote
ATV



Joined: 31 Aug 2004
Posts: 109
Location: Finland
ATV 27 Jul 2007, 07:09
I found solution, it was almost too easy.
Updated Alarm v0.11 in project area
Code:
LOCALE_USER_DEFAULT = 0400h
proc get_weekday_names
local temp_date:SYSTEMTIME
   push    ebx edi
     mov     edi,weekdays4
       mov     ebx,23
      .new_day:
       mov     [temp_date.wDay],bx     ; 23.july.2007 is monday
    mov     [temp_date.wMonth],7
        mov     [temp_date.wYear],2007
      lea     edx,[temp_date]
     invoke  GetDateFormat,LOCALE_USER_DEFAULT,0,edx,day_name_format,edi,8
       add     edi,4
       inc     ebx
 cmp     ebx,30                  ; loop until full week is done
      jb      .new_day
    mov     byte [edi],0
        pop     edi ebx
     ret
endp

day_name_format db 'ddd   ',0
weekdays4 db 'Mon Tue Wed Thu Fri Sat Sun     ',0 ; 4 extra bytes for read buffer    
Post 27 Jul 2007, 07:09
View user's profile Send private message Reply with quote
shoorick



Joined: 25 Feb 2005
Posts: 1614
Location: Ukraine
shoorick 27 Jul 2007, 07:38
yes, it works ok
Post 27 Jul 2007, 07:38
View user's profile Send private message Visit poster's website Reply with quote
peter



Joined: 09 May 2006
Posts: 63
peter 29 Jul 2007, 23:04
Use GetLocaleInfo function with LOCALE_SABBREVDAYNAME1, LOCALE_SABBREVDAYNAME2, etc.
Post 29 Jul 2007, 23:04
View user's profile Send private message Visit poster's website Reply with quote
ATV



Joined: 31 Aug 2004
Posts: 109
Location: Finland
ATV 31 Jul 2007, 07:05
peter, thanks. I knew there must be some API to get it, I just didn't find it. Magic words "Locale Information" and there are more useful local stuff.
Post 31 Jul 2007, 07:05
View user's profile Send private message Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 31 Jul 2007, 09:00
Agreed. Windows has alot of fancy features like this that are nice to have, we just don't know where they are or, worse off, that they even exist. For all i know, there could be a function in windows that does the message loop for me. There might even be a way to clear the console window without throwing out a bunch of spaces after resetting position to 0,0 or using system("CLS") which is slow.
Post 31 Jul 2007, 09:00
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.