News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

Date & Time in Sydney, New South Wales. Australia

Started by herge, October 07, 2013, 10:29:41 PM

Previous topic - Next topic

herge

 Hi Masm32 coders:

Are we all comfy got your supply of paint bombs for your
next running race. Don't leave home with out em.
Paint the Red light district Red, like in Kitchener, King @Cedar.
Further delay for Food and Drink!
The Proggie:

SYDTIM.ASM Thursday, October 03, 2013 4:43:52 PM
; Modified Monday, October 07, 2013 6:45:03 AM
; Program displays the Time(s) in Australia &
; England.
;

       include \masm32\include\masm32rt.inc

.data
            public stmA, stmUK
stmUK       SYSTEMTIME<>
stmA        SYSTEMTIME<>; Australia
lcidUK      dd  2057    ; United Kingdom i e England, Scotland, Wales, etc.
lcidA       dd  3081; Australia
LastDay     dd  0;
NextDay     dd  0; Tomorrow or Next day this will be a ONE
LeapYear    dd  0; 1 is Leap Year
MaxDayInMonth DWORD 00,31,28,31,30,31,30,31,31,30,31,30,31
ATime       DWORD 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 , 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8
            dd -1; EOF
ATimeDelta  DWORD 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
            dd -1; EOF             
                db 0   
dtbufEb     db " "; Space           
dtbufE      db 260 dup(0); England UTC(2057)
            dw 0
            db 0
dtbufAb     db " "
dtbufA      db 260 dup(0)
            dw 0
AppNameA    db "Date & Time in Sydney, New South Wales, Australia",0
AppNameE    db "Date & Time in London, England ", 0
crlf        db 13, 10, 0
tf          db "HH':'mm':'ss tt", 0
dfo         db " dddd, MMMM, dd, yyyy", 0
Tgmt        db 9, 9, " GMT ", 0; Greenwich Mean Time
Tbst        db 9, " BST ",  0; British Summer Time
Taedt       db  " AEDT ", 0; Auutralia Eastern Daylight Time
            db 0
.code
     align 8
     public FindLastDay
FindLastDay proc uses ebx
;
; Find Last Day in Month from Table MaxDayInMonth
;
     xor eax, eax
     mov LastDay, eax; Clear LastDay
     mov NextDay, eax; Clear NextDay
     mov LeapYear, eax; Clear LeapYear
     mov ax,  word ptr stmA.wMonth
     mov eax, MaxDayInMonth[eax*DWORD]; Get Maxium Days in Month i e Last Day ie 28,29,30, or 31
     mov LastDay, eax; save it!
     mov ax, word ptr stmA.wHour
     mov ebx, ATimeDelta[ eax*DWORD ]; Get Sydney Time
     and ebx, ebx
     jz FindLastDayX
     mov eax, LastDay
     cmp eax, 28; less than 28?
     jnc @F
     ; < than 28 No overflow Possible
     mov ax, word ptr stmA.wDay
     inc ax
     mov stmA.wDay, ax
     jmp FindLastDayX
@@:
     cmp ax, stmA.wDay
     jz FindLastDayNextMonth
     mov ax, word ptr stmA.wDay
     inc ax
     mov stmA.wDay, ax
     jmp FindLastDayX
     
FindLastDayNextMonth:
     mov ax, 1; First Day
     mov stmA.wDay, ax
     mov ax, word ptr stmA.wMonth
     inc ax
     mov stmA.wMonth, ax; Save Next Month
     cmp ax, 13; ? Mext Year i e is January Next Year(Overflow)
     jnz FindLastDayX
     mov ax, 1
     mov stmA.wDay, ax; First Day Next Month
     mov stmA.wMonth, ax; First Month January
     mov ax, word ptr stmA.wYear
     inc ax
     mov stmA.wYear, ax 
FindLastDayX:
     ret
FindLastDay endp
HourRollOver proc uses ebx edx
;
; The Hour has got to 24 and has to roll over to Zero
; and add one to stmA.wDay.
;
     xor eax, eax
     mov LastDay, eax   ; Clear LastDay
     mov LeapYear, eax  ; Clear LeapYear
     mov NextDay, eax   ; Clear NextDay
     mov ax,  word ptr stmA.wMonth
     mov eax, MaxDayInMonth[eax*DWORD]; Get Maxium Days in Month i e Last Day ie 28,29,30, or 31
     mov bx, stmA.wMonth
     cmp bx, 2
     jnz @F
     ; Leap Year Logic for February
     mov bx, stmA.wYear
     ; if even divided by 100 Not Leap Year.
     ; if divibile by 4 is leap year.
     ; if divisble by 400 is leap year.
     xor edx, edx
     mov ax, stmA.wYear
     mov bx, 100
     div bx
     and dx, dx
     jz HourRollOverX
     xor edx, edx
     mov bx, 4
     mov ax, stmA.wYear
     div bx
     and dx, dx
     jnz @F
     inc dx
     mov LeapYear, edx
     mov ax, 29; is Leap Year
     mov LastDay, eax; save it!
@@:     
     mov bx, stmA.wDay
     cmp ax, bx
     jz MonthRollOver
     inc bx
     mov stmA.wDay, bx
     jmp HourRollOverX
MonthRollOver:
     mov bx, stmA.wMonth
     cmp bx, 12
     jz YearRollOver
     inc bx
     mov stmA.wMonth, bx
     jmp HourRollOverX
YearRollOver:
     ; First day in January Next Year
     xor bx, bx
     inc bx
     mov stmA.wMonth, bx
     mov    stmA.wDay, bx
     mov bx, stmA.wYear
     inc bx
     mov stmA.wYear, bx
     jmp HourRollOverX
HourRollOverX:
     ret
HourRollOver endp     

     align 8
insertTime proc           
      pushad
      mov eax,esp
      INVOKE  GetTimeFormat, 2057, TIME_FORCE24HOURFORMAT, addr stmUK, addr tf, esi, 32
      ; 2057 UK to get AM/PM??
      add esp,32
      ret
insertTime endp

      align 8
insertTimeNSW proc           
      pushad
      mov eax,esp
      INVOKE  GetTimeFormat, 2057, TIME_FORCE24HOURFORMAT, addr stmA, addr tf, esi, 32
      ; 2057 UK to get AM/PM??
      add esp,32
      ret
insertTimeNSW endp

        align 8
start proc
      invoke GetSystemTime, addr stmUK  ; GMT + 0
      invoke GetSystemTime, addr stmA   ; GMT + 10
      ; Kludge to get BST British Summer Time
      mov ax, stmUK.wHour
      inc ax
      mov stmUK.wHour, ax
      cmp ax, 24
      jnz @F
      xor ax, ax
      mov stmUK.wHour, ax
      ; Last Day Logic Goes Here??(insert)
      inc eax
      mov NextDay, eax
      call HourRollOver
      jmp skipFindLastDay       

@@:     
     
      call FindLastDay
     
skipFindLastDay:     
     
      invoke GetDateFormat, lcidUK, 0, addr stmUK, addr dfo, addr dtbufE, 260
      and eax, eax
      jz ErGDFEngland

      lea esi, offset dtbufE
      add esi , eax  ; eax is len of format
      mov byte ptr [ esi - 1 ] , " "
      sub eax, eax; Clear eax
      mov ax, stmUK.wHour
      mov eax, ATime[eax*DWORD]
      mov stmA.wHour, ax

      public stop
stop::
      call FindLastDay

      call insertTime
 
      invoke GetDateFormat, lcidA, NULL,  ADDR  stmA, ADDR dfo, ADDR dtbufA, sizeof dtbufA

      and eax, eax
      jz ErGDFAustralia
     
      lea esi, offset dtbufA
      add esi , eax  ; eax is len of format
      mov byte ptr [ esi - 1 ] , " "
      call insertTimeNSW

      invoke MessageBox, 0, addr dtbufE, addr AppNameE, MB_OK; England Time GMT+0
      invoke MessageBox, 0, addr dtbufA, addr AppNameA, MB_OK; Sydney Time  GMT+!0
      invoke StdOut, addr crlf
      invoke StdOut, addr dtbufEb
      invoke StdOut, addr Tgmt
      invoke StdOut, addr crlf
      invoke StdOut, addr dtbufAb
      invoke StdOut, addr Taedt
      invoke StdOut, addr crlf
      jmp sydtimX
ErGDFAustralia:
      print " << Error GDF Australia >> ", 13,10,7
      jmp sydtimX
ErGDFEngland:
      print " << Error GDF England >> ", 13, 10,  7
 
sydtimX:
      inkey  " << Waiting ... >> ", 13, 10, 7
      exit
      ret
start   endp
        end start


Yes we had to cheat the GetSystemTime does not get the time
in England, it's off by one so we do the usual kludge code to
get BST. Then we use a Table thats off by Ten to get Austaralia
Eastern Daylight Time.

Whether it works after next time change near end of October
or is it early November, I do not knew. The Leap Year logic has
not really been tested!
Regards herge
Read "Slow Death by Rubber Duck"
for chemical Laughs.

herge

#1
 Hi MASM32 MACRO Coders

RemZeroXBuf MACRO REQ:BufName
      lea esi,offset BufName
      mov byte ptr [ esi - 1 ], " "
      ENDM


Enjoy!

MACRO Coders do it with less Typeing!

Regards herge
Read "Slow Death by Rubber Duck"
for chemical Laughs.

qWord

Quote from: herge on October 08, 2013, 06:13:33 AMRemZeroXBuf MACRO REQ:BufName
      lea esi,offset BufName
      mov byte ptr [ es - 1 ], " "
      ENDM


Enjoy!
:icon_confused:
MREAL macros - when you need floating point arithmetic while assembling!

jj2007

herge,

you probably meant:
mov byte ptr [ esi - 1 ], 0

Try also
mov byte ptr BufName, 0

By the way, you might consider keeping only one of your "date & time" threads, instead of opening a new one for every new location :icon14:

herge


Hi JJ2007:

Try also
mov byte ptr BufName, 0

This will work but since zero is first thing in buffer you will not
see anything?

You will get this if LCID is invalid and you get a Zero length
ASCII string which will be very Short and too the Point and
say Nothing at All.

It took me a long time to figure this out and after a long session with the EXE
in windbg.
Regards herge
Read "Slow Death by Rubber Duck"
for chemical Laughs.

Adamanteus

 Maybe to you will help POSIX TZ distribution, that's from standard :eusa_boohoo:

herge


The latest and greatest. The last Day of the Month Logic
has not really been tested.
But here's what we got now:

; SYDTIM.ASM Thursday, October 03, 2013 4:43:52 PM
; Modified Wednesday, October 09, 2013 10:17:51 AM
; Program displays the Time(s) in Australia &
; England.
;

       include \masm32\include\masm32rt.inc

;
; Remove Zero At End of Buffer NACRO. X is End or Exit
;
   
remzeroXbuf MACRO BufName:REQ
       lea esi, offset BufName
       add esi, eax
       mov byte ptr [ esi - 1 ], " "
       ENDM

.data
            public stmA, stmUK
stmUK    SYSTEMTIME<>
stmA       SYSTEMTIME<>; Australia
lcidUK      dd  2057    ; United Kingdom i e England, Scotland, Wales, etc.
lcidA       dd  3081; Australia
LastDay     dd  0;
NextDay     dd  0; Tomorrow or Next day this will be a ONE
LeapYear    dd  0; 1 is Leap Year
MaxDayInMonth DWORD 00,31,28,31,30,31,30,31,31,30,31,30,31
ATime       DWORD 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 , 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8
            dd -1; EOF
ATimeDelta  DWORD 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
            dd -1; EOF             
            db 0   
dtbufEb     db " "; Space           
dtbufE      db 260 dup(0); England UTC(2057)
            dw 0
            db 0
dtbufAb     db " "
            public dtbufA
dtbufA      db 260 dup(0)
                dw 0
CopyBuf     db 560 dup(0)
                   dw 0           
AppNameA    db "Date & Time in Sydney, New South Wales, Australia", 0
AppNameE    db "Date & Time in London, England ", 0
AppNameE_A  db "Date + Time in BST and AEDT Time Zones", 0
crlf        db 13, 10, 0
tf          db "HH':'mm':'ss tt", 0
dfo         db " dddd, MMMM, dd, yyyy", 0
Tgmt        db " GMT ", 0; Greenwich Mean Time
Tbst        db " BST ", 0; British Summer Time
Taedt       db " AEDT ", 0; Auutralia Eastern Daylight Time
TLondon     db " London ", 0
TSydney     db " Sydney ", 0
            db 0
.code
     align 8
     public FindLastDay
FindLastDay proc uses ebx
;
; Find Last Day in Month from Table MaxDayInMonth
;
     xor eax, eax
     mov LastDay, eax; Clear LastDay
     mov NextDay, eax; Clear NextDay
     mov LeapYear, eax; Clear LeapYear
     mov ax,  word ptr stmA.wMonth
     mov eax, MaxDayInMonth[eax*DWORD]; Get Maxium Days in Month i e Last Day ie 28,29,30, or 31
     mov LastDay, eax; save it!
     mov ax, word ptr stmA.wHour
     mov ebx, ATimeDelta[ eax*DWORD ]; Get Sydney Time
     and ebx, ebx
     jz FindLastDayX
     mov eax, LastDay
     cmp eax, 28; less than 28?
     jnc @F
     ; < than 28 No verflow Possible
     mov ax, word ptr stmA.wDay
     inc ax
     mov stmA.wDay, ax
     jmp FindLastDayX
@@:
     cmp ax, stmA.wDay
     jz FindLastDayNextMonth
     mov ax, word ptr stmA.wDay
     inc ax
     mov stmA.wDay, ax
     jmp FindLastDayX
     
FindLastDayNextMonth:
     mov ax, 1; First Day
     mov stmA.wDay, ax
     mov ax, word ptr stmA.wMonth
     inc ax
     mov stmA.wMonth, ax; Save Next Month
     cmp ax, 13; ? Mext Year i e is January Next Year(Overflow)
     jnz FindLastDayX
     mov ax, 1
     mov stmA.wDay, ax; First Day Next Month
     mov stmA.wMonth, ax; First Month January
     mov ax, word ptr stmA.wYear
     inc ax
     mov stmA.wYear, ax 
FindLastDayX:
     ret
FindLastDay endp
     public HourRollOver
HourRollOver proc uses ebx edx
;
; The Hour has got to 24 and has to roll over to Zero
; and add one to stmA.wDay.
;
     xor eax, eax
     mov LastDay, eax   ; Clear LastDay
     mov LeapYear, eax  ; Clear LeapYear
     mov NextDay, eax   ; Clear NextDay
     mov ax,  word ptr stmA.wMonth
     mov eax, MaxDayInMonth[eax*DWORD]; Get Maximum Days in Month i e Last Day ie 28,29,30, or 31
     mov bx, stmA.wMonth
     cmp bx, 2
     jnz @F
     ; Leap Year Logic for February
     mov bx, stmA.wYear
     ; if even divided by 100 Not Leap Year.
     ; if divibile by 4 is leap year.
     ; if divisble by 400 is leap year.
     xor edx, edx; Clear For Division
     mov ax, stmA.wYear
     mov bx, 100
     div bx
     and dx, dx
     jz HourRollOverX
     xor edx, edx
     mov bx, 4
     mov ax, stmA.wYear
     div bx
     and dx, dx; Is Remainder zero
     jnz @F
     inc dx; Turn LeapTear ON!
     mov LeapYear, edx
     mov ax, 29; is Leap Year LastDay = 29
     mov LastDay, eax; save it!
@@:     
     mov bx, stmA.wDay
     cmp ax, bx
     jz MonthRollOver
     inc bx
     mov stmA.wDay, bx
     jmp HourRollOverX
MonthRollOver:
     mov bx, stmA.wMonth
     cmp bx, 12
     jz YearRollOver
     inc bx; Add One to Nonth
     mov stmA.wMonth, bx; Save Month
     jmp HourRollOverX
YearRollOver:
     ; First day in January Next Year
     xor bx, bx
     inc bx
     mov stmA.wMonth, bx; Save January
     mov stmA.wDay, bx; Save Day One
     mov bx, stmA.wYear
     inc bx; Add one to wYear
     mov stmA.wYear, bx; Save stmA.WYear
     jmp HourRollOverX; over kill!
HourRollOverX:
     ret
HourRollOver endp     

     align 8
     public insertTime
insertTime proc           
      pushad
      mov eax,esp
      INVOKE  GetTimeFormat, 2057, TIME_FORCE24HOURFORMAT, addr stmUK, addr tf, esi, 32
      ; 2057 UK to get AM/PM??
      add esp,32
      ret
insertTime endp

      align 8
      public insertTimeNSW; NSW New South Wales a state in Australia
insertTimeNSW proc           
      pushad
      mov eax,esp
      INVOKE  GetTimeFormat, 2057, TIME_FORCE24HOURFORMAT, addr stmA, addr tf, esi, 32
      ; 2057 UK to get AM/PM??
      add esp,32
      ret
insertTimeNSW endp

      align 8
      public start
start proc
      invoke GetSystemTime, addr stmUK  ; GMT + 0
      invoke GetSystemTime, addr stmA   ; GMT + 10
      ; Kludge to get BST British Summer Time
      mov ax, stmUK.wHour
      inc ax
      mov stmUK.wHour, ax
      cmp ax, 24
      jnz @F
      xor eax, eax
      mov stmUK.wHour, ax
      ; Last Day Logic Goes Here??(insert)
      inc eax
      mov NextDay, eax
      call HourRollOver
      jmp skipFindLastDay       

@@:     
     
      call FindLastDay
     
skipFindLastDay:     
     
      invoke GetDateFormat, lcidUK, 0, addr stmUK, addr dfo, addr dtbufE, 260
      and eax, eax
      jz ErGDFEngland

      remzeroXbuf dtbufE
     
      sub eax, eax; Clear eax
      mov ax, stmUK.wHour
      mov eax, ATime[eax*DWORD]; Table off by Ten so we are getting GMT + 10
      mov stmA.wHour, ax; save ARDT in wHour
      mov eax, ATimeDelta[eax*DWORD]; Get Day if eax is One adjust stmA.WDay
      and eax, eax
      jz @F
      mov ax, stmA.wDay
      inc ax
      mov stmA.wDay, ax
      ; ** No OverFlow Logic **

@@:

      public stop
stop::
      call FindLastDay

      call insertTime
 
      invoke GetDateFormat, lcidA, NULL,  ADDR  stmA, ADDR dfo, ADDR dtbufA, sizeof dtbufA

      and eax, eax
      jz ErGDFAustralia

      remzeroXbuf dtbufA
     
      call insertTimeNSW

      invoke MessageBox, 0, addr dtbufE, addr AppNameE, MB_OK; England Time GMT + 0
      invoke MessageBox, 0, addr dtbufA, addr AppNameA, MB_OK; Sydney Time  GMT + 10
   
      invoke StdOut, addr crlf
      invoke StdOut, addr dtbufEb
      invoke StdOut, addr Tbst 
      invoke StdOut, addr crlf
      invoke StdOut, addr dtbufAb
      invoke StdOut, addr Taedt
      invoke StdOut, addr crlf
      invoke StdOut, addr CopyBuf
      invoke StdOut, addr crlf
 
      mov edi, offset CopyBuf
      mov ecx, 560
      mov esi, offset TLondon 
@@:
      lodsb
      and al, al
      jz @F
      stosb
      dec ecx
      jnz @B
      jmp ECXZero
     
@@:     
      mov ESI, offset dtbufE   
GetBufE:
      lodsb
      and al, al
      jz GetBufA
      stosb
      dec ecx
      jnz GetBufE

      public GetBufA
GetBufA::
      mov esi, offset Tbst; Insert British Sunmmer Time
@@:
      lodsb
      and al,al
      jz @F     
      stosb
      dec ecx
      jz GetBufAX
      jmp @B
@@:     
      mov word ptr [edi], 0A0Dh ; New Line
      add edi, 2; ** Add Two to Destination **
      dec ecx
      jz GetBufAX
      dec ecx
      jz GetBufAX
      mov esi,offset TSydney 
@@:
      lodsb
      and al, al
      jz @F
      stosb
      dec ecx
      jnz @B
      jmp ECXZero
@@:
      mov esi, offset dtbufA
GetBufA1:
      lodsb
      and al, al
      jz GetBufAX
      stosb
      dec ecx
      jnz GetBufA1
GetBufAX:
      mov esi, offset Taedt; insert Australian Eastern Daylight Time
@@:
      lodsb
      and al, al
      jz @F
      stosb
      dec ecx
      jnz @B
@@:               
      xor al,al
      stosb
      dec ecx
      jz @F
      and ecx, ecx
      jz @F 
      dec ecx
@@:
ECXZero:
      and ecx, ecx
     
      invoke MessageBox, 0, addr CopyBuf, addr AppNameE_A, MB_OK; England + Australia
     
      jmp sydtimX
ErGDFAustralia:
      print " << Error GDF Australia >> ", 13,10,7
      jmp sydtimX
ErGDFEngland:
      print " << Error GDF England >> ", 13, 10,  7
 
sydtimX:
      inkey  " << Waiting ... >> ", 13, 10, 7
      exit
      ret
start   endp
        end start


That's All Folks!
Regards herge
Read "Slow Death by Rubber Duck"
for chemical Laughs.

herge


Hi Masm32 Coders:

This is the latest version of SYDTIM.ASM. I think most of the bugs have
been removed. But I suspect when the clocks change in the beginning
of November or end of October it will need a few Edits?

; SYDTIM.ASM Thursday, October 03, 2013 4:43:52 PM
; Modified Friday, October 25, 2013 5:33:02 AM
; Program displays the Time(s) in Australia &
; England.
;

       include \masm32\include\masm32rt.inc

;
; Remove Zero At End of Buffer MACRO. X is End or Exit
;
   
remzeroXbuf MACRO BufName:REQ
       lea esi, offset BufName
       add esi, eax
       mov byte ptr [ esi - 1 ], " "
       ENDM

GetTimeAndDelta MACRO stmName:REQ, TimeName:REQ, DeltaName:REQ
      movzx eax, word ptr stmName.wHour
      mov eax, TimeName [ eax*DWORD ]
      mov stmName.wHour, ax; save stmName.wHour
      mov eax, DeltaName [ eax*DWORD ]; Get Day if eax is One adjust stmName.WDay
      ENDM

.data
            public stmA, stmH, stmL, stmUK, stmNY
stmUK       SYSTEMTIME<>; United Kingdom i e England, Scotland, Wales, etc.
stmA        SYSTEMTIME<>; Australia
stmH        SYSTEMTIME<>; Hawaii
stmL        SYSTEMTIME<>; California
stmNY       SYSTEMTIME<>; New York
lcidUK      dd  2057    ; United Kingdom i e England, Scotland, Wales, etc.
lcidNY      dd  1033    ; United States of America
lcidA       dd  3081    ; Australia
MaxDay      dd  0;
NextDay     dd  0; Tomorrow or Next day this will be a ONE
LeapYear    dd  0; 1 is Leap Year
MaxDayInMonth DWORD 00,31,28,31,30,31,30,31,31,30,31,30,31
ATime       DWORD 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 , 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9
            dd -1; EOF
ATimeDelta  DWORD 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
            dd -1; EOF
HTime       DWORD 13, 14, 15, 16, 17, 18, 19, 20, 21, 22 , 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12
            dd -1; EOF
HTimeDelta  DWORD 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
            dd -1; EOF

LTime       DWORD 16, 17, 18, 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
            dd -1; EOF
LTimeDelta  DWORD 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
            dd -1; EOF 
NYTime      DWORD 19, 20, 21, 22, 23, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18
            dd -1; EOF
NYTimeDelta DWORD 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
            dd -1; EOF

            public dtbufE, dtbufH, dtbufL, dtbufNY, dtbufA
            public dtbufEb, dtbufHb, dtbufNYb, dtbufAb           
            db 0   
dtbufEb     db " "; Space           
dtbufE      db 260 dup(0); England UTC(2057)
            dw 0
           
            db 0   
dtbufHb     db " "; Space           
dtbufH      db 260 dup(0); Hawaii UTC(2057)
            dw 0
           
            db 0   
dtbufLb     db " "; Space
            public dtbufL           
dtbufL      db 260 dup(0); California UTC(2057)
            dw 0
            db 0   
dtbufNYb    db " "; Space           
dtbufNY     db 260 dup(0); California UTC(2057)
            dw 0

            db 0
dtbufAb     db " "
            public dtbufA
dtbufA      db 260 dup(0)
            dw 0
CopyBuf     db 2800 dup(0)
            dw 0           
AppNameA    db "Date & Time in Sydney, New South Wales, Australia", 0
AppNameE    db "Date & Time in London, England ", 0
AppNameH    db "Date & Time in Honolulu, Hawaii, USA ", 0
AppNameL    db "Date & Time in Los Angeles, California, USA ", 0
AppNameNY   db "Date & Time in New York City, New York, USA ", 0
AppNameE_A  db "Date + Time in HST and BST and AEDT Time Zones", 0
crlf        db 13, 10, 0
tf          db "HH':'mm':'ss tt", 0
dfo         db " dddd, MMMM, dd, yyyy", 0
Thst        db " HST ", 0; Hawaiian Standard Time GMT - 11; Also Time in Alaska
Tpst        db " PDT ", 0; Pacific Standard Time  GMT - 8; Time in Los Angeles
Test_       db " EST ", 0; Eastern Standard Time  GMT - 5; Time in New York City     
Tgmt        db " GMT ", 0; Greenwich Mean Time    GMT + 0; Greenwich, England 
Tbst        db " BST ", 0; British Summer Time    GMT + 1; London, England
Taedt       db " AEDT ", 0; Australia Eastern Daylight Time GMT + 10
TLondon     db " London ", 0
TSydney     db " Sydney ", 0
THonolulu   db " Honolulu ", 0
TLosAngeles db " Los Angeles ", 0
TNewYork    db " New York City ", 0
            db 0
.code
     align 8
     public FindLastDay
FindLastDay proc uses ebx
;
; Find Last Day in Month from Table MaxDayInMonth
;
     xor eax, eax
     mov MaxDay, eax; Clear MaxDay
     mov NextDay, eax; Clear NextDay
     mov LeapYear, eax; Clear LeapYear
     mov ax,  word ptr stmA.wMonth
     mov eax, MaxDayInMonth[eax*DWORD]; Get Maxium Days in Month i e Last Day ie 28,29,30, or 31
     mov MaxDay, eax; save it!
     mov ax, word ptr stmUK.wHour
     mov ebx, ATimeDelta[ eax*DWORD ]; Get Sydney Time
     and ebx, ebx
     jz FindLastDayX
     mov ax, stmUK.wDay
     add ax, bx
     mov stmA.wDay, ax
     cmp eax, 28; less than 28?
     jnc @F
     ; < than 28 No verflow Possible
     jmp FindLastDayX
@@:
     cmp ax, stmUK.wDay
     jz FindLastDayNextMonth
   
     jmp FindLastDayX
     
FindLastDayNextMonth:
     mov ax, 1; First Day
     mov stmUK.wDay, ax
     mov ax, word ptr stmUK.wMonth
     inc ax
     mov stmUK.wMonth, ax; Save Next Month
     cmp ax, 13; ? Mext Year i e is January Next Year(Overflow)
     jnz FindLastDayX
     mov ax, 1
     mov stmUK.wDay, ax; First Day Next Month
     mov stmUK.wMonth, ax; First Month January
     mov ax, word ptr stmUK.wYear
     inc ax
     mov stmUK.wYear, ax 
FindLastDayX:
     ret
FindLastDay endp

       align 8
       public TestLeapYear
TestLeapYear proc uses ebx edx
     xor eax, eax
     mov LeapYear, eax  ; Clear LeapYear
     mov bx, stmUK.wYear
     bt bx, 0
     jc TestLeapYearX; is Odd
     ; if even divided by 100 Not Leap Year.
     ; if divibile by 4 is leap year.
     ; if divisble by 400 is leap year.
     xor edx, edx; Clear For Division
     mov ax, stmUK.wYear
     mov bx, 400
     div bx
     and dx, dx
     jnz TestLeapYearA
TestLeapYearYes:
     inc edx
     mov LeapYear, edx
     mov bx, stmUK.wMonth
     cmp bx, 2
     jnz @F
     ; February Leap Year MaxDay
     mov ebx, 29
     mov MaxDay, ebx
@@:     
     ret
TestLeapYearA:
     xor edx, edx; Clear For Division
     mov ax, stmA.wYear
     mov bx, 100
     div bx
     and dx, dx
     jz TestLeapYearX
     xor edx, edx; Clear For Division
     mov ax, stmA.wYear
     mov bx, 4
     div bx
     and dx, dx
     jz TestLeapYearYes
TestLeapYearX:
     ret
TestLeapYear endp

     public HourRollOver
     align 8
HourRollOver proc uses ebx edx
;
; The Hour has got to 24 and has to roll over to Zero
; and add one to stmUK.wDay.
;
     xor eax, eax
     mov MaxDay, eax    ; Clear MaxDay
     mov LeapYear, eax  ; Clear LeapYear
     mov NextDay, eax   ; Clear NextDay
     mov ax,  word ptr stmUK.wMonth
     mov eax, MaxDayInMonth[eax*DWORD]; Get Maximum Days in Month i e Last Day ie 28,29,30, or 31
     mov bx, stmUK.wMonth
     mov bx, stmUK.wYear
     call TestLeapYear
@@:     
     mov bx, stmUK.wDay
     cmp ax, bx
     jnz HourRollOverX
MonthRollOver:
     mov bx, stmUK.wMonth
     cmp bx, 12
     jz YearRollOver
     inc bx; Add One to Nonth
     mov stmUK.wMonth, bx; Save Month
     jmp HourRollOverX
YearRollOver:
     ; First day in January Next Year
     mov bx, 1
     mov stmUK.wMonth, bx; Save January
     mov stmUK.wDay, bx; Save Day One
     mov bx, stmA.wYear
     inc bx; Add one to wYear
     mov stmUK.wYear, bx; Save stmA.WTear
     jmp HourRollOverX; over kill!
HourRollOverX:
     ret
HourRollOver endp     

     align 8
     public insertTime
insertTime proc           
      pushad
      mov eax,esp
      INVOKE  GetTimeFormat, 2057, TIME_FORCE24HOURFORMAT, addr stmUK, addr tf, esi, 32
      ; 2057 UK to get AM/PM??
      add esp,32
      ret
insertTime endp

      align 8
      public insertTimeNSW; NSW New South Wales a state in Australia
insertTimeNSW proc           
      pushad
      mov eax,esp
      INVOKE  GetTimeFormat, 2057, TIME_FORCE24HOURFORMAT, addr stmA, addr tf, esi, 32
      ; 2057 UK to get AM/PM??
      add esp,32
      ret
insertTimeNSW endp

      align 8
      public insertTimeLAX
insertTimeLAX proc           
      pushad
      mov eax,esp
      INVOKE  GetTimeFormat, 2057, TIME_FORCE24HOURFORMAT, addr stmL, addr tf, esi, 32
      ; 2057 UK to get AM/PM??
      add esp,32
      ret
insertTimeLAX endp

      align 8
      public insertTimeHNL
insertTimeHNL proc           
      pushad
      mov eax,esp
      INVOKE  GetTimeFormat, 2057, TIME_FORCE24HOURFORMAT, addr stmH, addr tf, esi, 32
      ; 2057 UK to get AM/PM??
      add esp,32
      ret
insertTimeHNL endp

      align 8
      public insertTimeJFK
insertTimeJFK proc           
      pushad
      mov eax,esp
      INVOKE  GetTimeFormat, 2057, TIME_FORCE24HOURFORMAT, addr stmNY, addr tf, esi, 32
      ; 2057 UK to get AM/PM??
      add esp,32
      ret
insertTimeJFK endp

      align 8
      public start
start proc
      invoke GetSystemTime, addr stmUK  ; GMT + 0
      invoke GetSystemTime, addr stmA   ; GMT + 10
      invoke GetSystemTime, addr stmH   ; GMT - 10
      invoke GetSystemTime, addr stmL   ; GMT - 8
      invoke GetSystemTime, addr stmNY  ; GMT - 5

      ; Kludge to get BST British Summer Time
     
      movzx eax, word ptr stmUK.wHour
      inc ax
      cmp ax, 24
      jnz @@1
@@M1:     
      mov ax, -1
@@1:     
      push eax
      inc eax
      mov NextDay, eax
      pop eax
      mov stmA.wHour, ax
      mov stmH.wHour, ax
      mov stmL.wHour, ax
      mov stmUK.wHour, ax
      mov stmNY.wHour, ax
      ; Last Day Logic Goes Here??(insert)
      call HourRollOver
      jmp skipFindLastDay       

@@:     
     
      call FindLastDay
     
skipFindLastDay:     
     
      invoke GetDateFormat, lcidUK, 0, addr stmUK, addr dfo, addr dtbufE, sizeof dtbufE
      and eax, eax
      jz ErGDFEngland

      remzeroXbuf dtbufE

      call insertTime
      public Sbst
Sbst::     
      ; Insert BST
      add esi, eax
      dec esi
      mov byte ptr [ esi  ] , " " ; Space
      mov edi,  offset Tbst
      xchg esi, edi
@@:
      lodsb
      and al, al
      stosb
      jnz @B     
      xchg esi, edi; Swap back
 
      invoke GetDateFormat, lcidUK, 0, addr stmH, addr dfo, addr dtbufH, sizeof dtbufH
      and eax, eax
      jz ErGDFHawaii

      remzeroXbuf dtbufH
      ; stmName:REQ, TimeName:REQ, DeltaName:REQ
      GetTimeAndDelta stmH, HTime, HTimeDelta
     
      call insertTimeHNL
      and eax, eax
      jz ErTimHNL

      ; Insert HST
      add esi, eax
      dec esi
      mov byte ptr [ esi  ] , " " ; Space
      mov edi,  offset Thst
      xchg esi, edi
@@:
      lodsb
      and al, al
      stosb
      jnz @B     
      xchg esi, edi; Swap back

      invoke GetDateFormat, lcidUK, 0, addr stmL, addr dfo, addr dtbufL, sizeof dtbufL
      and eax, eax
      jz ErGDFCalifornia

      remzeroXbuf dtbufL
      ; stmName:REQ, TimeName:REQ, DeltaName:REQ
      GetTimeAndDelta stmL, LTime, LTimeDelta
     
      call insertTimeLAX
      and eax, eax
      jz ErTimLAX

      ; Insert PST
      add esi, eax
      dec esi
      mov byte ptr [ esi  ] , " " ; Space
      mov edi,  offset Tpst
      xchg esi, edi
@@:
      lodsb
      and al, al
      stosb
      jnz @B     
      xchg esi, edi; Swap back

      invoke GetDateFormat, lcidUK, 0, addr stmUK, addr dfo, addr dtbufE, sizeof dtbufE
      and eax, eax
      jz ErGDFEngland
      remzeroXbuf dtbufE

      call insertTime
      and eax, eax
      jz ErTimUK
      ; Insert BST here ESI > Start of Time eax is Length of Twelve 0Ch or 12 decimal.
      ; Insert BST
      add esi, eax
      dec esi
      mov byte ptr [ esi  ] , " " ; Space
      mov edi,  offset Tbst
      xchg esi, edi
@@:
      lodsb
      and al, al
      stosb
      jnz @B     
      xchg esi, edi; Swap back

      invoke GetDateFormat, lcidUK, 0, addr stmA, addr dfo, addr dtbufA, sizeof dtbufA
      and eax, eax
      jz ErGDFAustralia

      remzeroXbuf dtbufA

      GetTimeAndDelta stmA, ATime, ATimeDelta

      call insertTimeNSW
      and eax, eax
      jz ErTimSYD

      ; Insert BST
      add esi, eax
      dec esi
      mov byte ptr [ esi  ] , " " ; Space
      mov edi,  offset Tbst
      xchg esi, edi
@@:
      lodsb
      and al, al
      stosb
      jnz @B     
      xchg esi, edi; Swap back

      invoke GetDateFormat, lcidUK, 0, addr stmNY, addr dfo, addr dtbufNY, sizeof dtbufNY
      and eax, eax
      jz ErGDFAustralia

      GetTimeAndDelta stmNY, NYTime, NYTimeDelta

      call insertTimeJFK
      and eax, eax
      jz ErTimJFK

      ; Insert EST
      add esi, eax
      dec esi
      mov byte ptr [ esi  ] , " " ; Space
      mov edi,  offset Test_
      xchg esi, edi
@@:
      lodsb
      and al, al
      stosb
      jnz @B     
      xchg esi, edi; Swap back
     
      public stop
stop::
      call FindLastDay

      invoke GetDateFormat, lcidA, NULL, ADDR stmA, ADDR dfo, ADDR dtbufA, sizeof dtbufA

      and eax, eax
      jz ErGDFAustralia

      remzeroXbuf dtbufA
     
      call insertTimeNSW
      and eax, eax
      jz ErTimSYD

     ; Insert AEDT
      add esi, eax
      dec esi
      mov byte ptr [ esi  ] , " " ; Space
      mov edi,  offset Taedt
      xchg esi, edi
@@:
      lodsb
      and al, al
      stosb
      jnz @B     
      xchg esi, edi; Swap back

      invoke GetDateFormat, lcidNY, NULL,  ADDR  stmNY, ADDR dfo, ADDR dtbufNY, sizeof dtbufNY

      and eax, eax
      jz ErGDFUSAJFK

      remzeroXbuf dtbufNY
       
      call insertTimeJFK
      and eax, eax
      jz ErTimJFK

     ; Insert EST
      add esi, eax
      dec esi
      mov byte ptr [ esi  ] , " " ; Space
      mov edi,  offset Test_
      xchg esi, edi
@@:
      lodsb
      and al, al
      stosb
      jnz @B     
      xchg esi, edi; Swap back
     
      invoke MessageBox, 0, addr dtbufE, addr AppNameE, MB_OK; England Time     GMT + 0
      invoke MessageBox, 0, addr dtbufA, addr AppNameA, MB_OK; Sydney Time      GMT + 10
      invoke MessageBox, 0, addr dtbufH, addr AppNameH, MB_OK; Honolulu Time    GMT - 11
      invoke MessageBox, 0, addr dtbufL, addr AppNameL, MB_OK; Los Angeles Time GMT - 8
      invoke MessageBox, 0, addr dtbufNY, addr AppNameNY, MB_OK; New York Time  GMT - 5

      invoke StdOut, addr crlf
      invoke StdOut, addr dtbufHb
      invoke StdOut, addr Thst
      invoke StdOut, addr THonolulu 
      invoke StdOut, addr crlf
      invoke StdOut, addr dtbufLb
      invoke StdOut, addr Tpst
      invoke StdOut, addr TLosAngeles
      invoke StdOut, addr crlf
      invoke StdOut, addr dtbufNYb
      invoke StdOut, addr Test_
      invoke StdOut, addr TNewYork
      invoke StdOut, addr crlf 
      invoke StdOut, addr dtbufEb
      invoke StdOut, addr Tbst
      invoke StdOut, addr TLondon
      invoke StdOut, addr crlf
      invoke StdOut, addr dtbufAb
      invoke StdOut, addr Taedt
      invoke StdOut, addr TSydney
      invoke StdOut, addr crlf
      invoke StdOut, addr CopyBuf
      invoke StdOut, addr crlf
 
      mov edi, offset CopyBuf
      mov ecx, sizeof CopyBuf; should be 2800? 
      mov esi, offset THonolulu
@@:
      lodsb
      and al, al
      jz @F
      stosb
      dec ecx
      jnz @B
      jmp ECXZero
     
@@:     
      mov ESI, offset dtbufH   
GetBufH:
      lodsb
      and al, al
      jz GetBufE
      stosb
      dec ecx
      jz BufferFull
      jnz GetBufH

      public GetBufE
GetBufE::
      mov word ptr [edi], 0A0Dh ; New Line
      add edi, 2; ** Add Two to Destination **
      dec ecx
      jz BufferFull
      dec ecx
      jz BufferFull
      mov esi, offset TLondon
@@:
      lodsb
      and al, al
      jz @F
      stosb
      dec ecx
      jnz @B
      jmp BufferFull
@@:
      mov esi, offset dtbufE
@@:
      lodsb
      and al, al
      jz @F
      stosb
      dec ecx
      jz BufferFull
      jmp @B
@@:
      mov word ptr [edi], 0A0Dh ; New Line
      add edi, 2; ** Add Two to Destination **
      dec ecx
      jz BufferFull
      dec ecx
      jz BufferFull
@@:
      mov esi, offset TLosAngeles
@@:
      lodsb
      and al, al
      jz @F
      stosb
      dec ecx
      jnz @B
      jmp ECXZero
@@:
      mov esi, offset dtbufL
@@:
      lodsb
      and al, al
      jz @F
      stosb
      dec ecx
      jnz @B
      jmp BufferFull
@@:
      mov word ptr [edi], 0A0Dh ; New Line
      add edi, 2; ** Add Two to Destination **
      dec ecx
      jz ECXZero
      dec ecx
      jz ECXZero
      mov esi, offset TNewYork
@@:
      lodsb
      and al ,al
      jz @F
      stosb
      dec ecx
      jz ECXZero
      jmp @B
@@:
      mov esi,offset dtbufNY
@@:
      lodsb
      and al, al
      jz @F
      stosb
      dec ecx
      jz ECXZero
      jmp @B
@@:
      mov word ptr [edi], 0A0Dh ; New Line
      add edi, 2; ** Add Two to Destination **
      dec ecx
      jz ECXZero
      dec ecx
      jz ECXZero
                             
      mov esi, offset TSydney
@@:
      lodsb
      and al, al
      jz @F
      stosb
      dec ecx
      jz ECXZero
      jmp @B 
@@:
      mov esi, offset dtbufA
@@: 
      lodsb
      and al, al
      jz @F
      stosb
      dec ecx
      jz ECXZero
      jmp @B
@@:
     
      public ECXZero
ECXZero::
      and ecx, ecx
      jz BufferFull
     
      invoke MessageBox, 0, addr CopyBuf, addr AppNameE_A, MB_OK; Hawaii + England + Australia
     
      jmp sydtimX
ErGDFAustralia:
      print " << Error GDF Australia >> ", 13,10,7
      jmp sydtimX
ErGDFEngland:
      print " << Error GDF England >> ", 13, 10,  7
      jmp sydtimX
ErGDFHawaii:
      print " << Error GDF Hawaii >> ", 13, 10, 7
      jmp sydtimX
ErGDFCalifornia:
      print " << Error GDF California >> ", 13, 10, 7
      jmp sydtimX
BufferFull:
      print " << Buffer Full ECX = Zero! >> ", 13, 10, 7
      jmp sydtimX
ErTimHNL:
      print " << Hawaii Time is Wrong >> ", 13, 10, 7
      jmp sydtimX
ErGDFUSAJFK:
      print " << Error GDF America New York >> ", 13, 10, 7
      jmp sydtimX
ErTimLAX:
      print " << California Time is Wrong >> ", 13, 10, 7
      jmp sydtimX
ErTimJFK:
      print " << New York Time is Wrong >> ", 13, 10, 7
      jmp sydtimX
ErTimSYD:
      print " << Sydney Time is Wrong >> ", 13, 10, 7
      jmp sydtimX
ErTimUK:
      print " << London Time is Wrong >> ", 13, 10,0
      jmp sydtimX                       
sydtimX:
      inkey  " << Waiting ... >> ", 13, 10, 7
      exit
      ret
start   endp
        end start


Happy coding and less Debugging?
Regards herge
Read "Slow Death by Rubber Duck"
for chemical Laughs.

herge



Hi Masm32 coders:

remzeroXbuf MACRO BufName:REQ
       lea esi, offset BufName
       add esi, eax
       mov byte ptr [ esi - 1 ], " "
       ENDM



A slightly better version of remzeroXbuf MACRO it removes the Zero at
end of buffer and makes it a space. The Length of buffer has to be
in eax else nothing happens?
Regards herge
Read "Slow Death by Rubber Duck"
for chemical Laughs.

herge


Hi Masm32 Coders:

SYDTIM.ASM has been updated.

The time for New Delhi, India might be off by 30 minutes!

DayLight savings logic is not implemented.
some Asian location might have the wrong time or tell
the time in England.

  Happy Coding and less debugging!
Regards herge
Read "Slow Death by Rubber Duck"
for chemical Laughs.

Gunther

Herge,

there's something wrong with your attachment. I can't extract it.

Gunther
You have to know the facts before you can distort them.

herge

Regards herge
Read "Slow Death by Rubber Duck"
for chemical Laughs.

Gunther

Herge,

7zip is a good tool and it's free. It's worth a try.

Gunther
You have to know the facts before you can distort them.

herge


Hi Gunther:

I have 7 zip but I don't knew how to use it!
This might take longer than I think.

It's more than 20k so it has to be an attachment,

Gunther pray to the Gods and Happy Guy Fawkes Day it's
November 5th.



Regards herge
Read "Slow Death by Rubber Duck"
for chemical Laughs.

herge

Regards herge
Read "Slow Death by Rubber Duck"
for chemical Laughs.