The MASM Forum Archive 2004 to 2012

General Forums => The Laboratory => Topic started by: GregL on July 21, 2007, 08:58:02 PM

Title: World Times
Post by: GregL on July 21, 2007, 08:58:02 PM
I hadn't posted any code here for quite a while so I decided to post this. Attached is a program that demonstrates how to determine the current time and date for any time zone in the world. It reads the time zone information from the Registry. I haven't built a GUI for it yet, I don't know if I will. If you find any mistakes, or if you find a time that is not correct, please let me know. Hopefully someone will find it useful.



[attachment deleted by admin]
Title: Re: World Times
Post by: GregL on July 22, 2007, 05:35:44 PM
Updated the zip. Fixed the PROTO for DayOfWeek.

Title: Re: World Times
Post by: hutch-- on July 22, 2007, 07:15:24 PM
Greg,

I have just tweaked it to build in masm32 and it looks good, works fine and would be useful to many people. If its OK with you I would like to include it in the next masm32 version.

I have attached the tweaked version for your approval.

[attachment deleted by admin]
Title: Re: World Times
Post by: GregL on July 22, 2007, 07:58:32 PM
Hutch,

Of course it's OK. It could be spiffed up some more, but it's good enough to demonstrate how to use the Time Zone information from the Windows Registry, which was my intent. I do have several more procedures that are built on the DATETIME typedef that I could put into a DateTime library for MASM32.

Thanks,

Greg
Title: Re: World Times
Post by: GregL on July 23, 2007, 12:35:54 AM
I updated the zip file in the first post. It is a version of WorldTimes that will build with MASM32 and it includes a DateTime Library for MASM32.

Title: Re: World Times
Post by: hutch-- on July 23, 2007, 02:10:16 AM
Greg,

Thanks for the effort, the demo builds fine and the library builds fine and looks great. I took the "c:" out of the paths in the demo so it would build on any partition that had masm32 installed on it.

Is there any chance of a minimum decription of what the functions do and how to use them ? Just a simple text file would make it a lot more usable in a hurry.
Title: Re: World Times
Post by: GregL on July 23, 2007, 03:45:41 AM
hutch,

OK, I'll work on some documentation. I'd like to do some more testing on the library too.

Title: Re: World Times
Post by: GregL on July 23, 2007, 08:12:01 PM
Hutch,

I uploaded a new file in the first post. It contains the WorldTimes program, the DateTime library and my attempt at some documentation for the DateTime library, it's just a plain text file. Creating the documentation was a good thing, I was able to double check all the parameters and return values. I made some modifications to some of the procedures in the library for error checking and return values. None of it made any difference to the WorldTimes program. The library could still use some more testing.

Title: Re: World Times
Post by: GregL on July 24, 2007, 12:18:58 AM
I uploaded a new file in the first post. I ran a bunch of tests on the DateTime library, there was a problem with CurrentTimeZoneName and DaysInMonth is still giving the wrong result. Everything else looks good. I don't have time to fix DaysInMonth right now, I'm going to the movie theater, I'll have a crack at it in the morning.

Title: Re: World Times
Post by: hutch-- on July 24, 2007, 04:27:48 AM
Gratsie.
Title: Re: World Times
Post by: GregL on July 24, 2007, 05:16:10 AM
I uploaded a new file in the first post. DaysInMonth is working correctly.

Title: Re: World Times
Post by: GregL on July 24, 2007, 06:41:53 PM
I updated the zip file in the first post, a procedure was missing, DateTimeToString. It converts a DATETIME to a ASCIIZ string using the system's default date and time formats. I modified the WorldTimes program to use that, it was using a forced 12-hour time format.



Title: Re: World Times
Post by: hutch-- on July 24, 2007, 07:16:59 PM
Demo works fine here and the documentation looks good and is clear to read.  :U
Title: Re: World Times
Post by: GregL on July 25, 2007, 02:18:26 AM
Hutch,

Thanks.

I updated the zip file in the first post. More improvements.

Attached is a test piece for the DateTime library.

[attachment deleted by admin]
Title: Re: World Times
Post by: GregL on August 04, 2007, 01:52:56 AM
I should mention that if the Windows OS is NT based you can use SystemTimeToTzSpecificLocalTime (http://msdn2.microsoft.com/en-us/library/ms724949.aspx) to convert a time in UTC to a particular time zone, it makes things a little easier, but not a lot.

Title: Re: World Times
Post by: GregL on August 04, 2007, 10:17:17 PM
I corrected some errors in the DateTime library and uploaded a new file in the first post. I separated the library and the WorldTimes program. The WorldTimes program has not changed.





Title: Re: World Times
Post by: GregL on August 05, 2007, 08:01:24 PM
I added a few functions to the DateTime library that I found I had a need for. I uploaded a new file in the first post. I dropped the plain text documentation and updated the CHM file.



Title: Re: World Times
Post by: GregL on August 07, 2007, 08:44:35 PM
I decided a couple of the functions I added were really just redundant and I removed them. I updated the DateTime library file in the first post. I'm going to try to leave the library alone.  :bg

Title: Re: World Times
Post by: Faiseur on August 11, 2007, 06:59:27 PM
Hello Greg.

The part in bold is missing in your documentation:

INVOKE MonthName, pdt, pszMonthName

And this procedure "MonthName" seems not to function correctly. Otherwise is very good, thanks !





Title: Re: World Times
Post by: GregL on August 11, 2007, 08:59:17 PM
Faiseur,

Thanks for pointing that out. I fixed the documentation. The MonthName procedure definitely had a problem. Somehow I skipped that procedure when doing my testing.  :red  It was missing a *4 in an index, old C habits. I uploaded a new file for the DateTime library in the first post. I also uploaded a new example program above. Thanks for the feedback.