1

I need to make a modification to a legacy app written in Turbo Pascal 7 which requires me to find out the current timezone offset. The program runs in a DOS box in a 32-bit XP environment.

Anybody know of a way of doing this?

** EDIT **

I probably should add that the reason for this question is because I want to know the UTC time , i.e. I want a way of calling a GetSystemTime equivalent from DOS.

rossmcm
  • 5,493
  • 10
  • 55
  • 118

1 Answers1

2

Try using an Exec statement in Pascal to run the DOS systeminfo command output with a pipe, then parse the resulting output using Pascal. Example...

c:\>systeminfo | find "Time Zone"
Time Zone:                 (UTC-05:00) Eastern Time (US & Canada)

c:\>

It takes a sec on Windows 7 to get the result but it should run faster on XP.

Rick Sarvas
  • 769
  • 10
  • 20
  • Clever. It's a shame it takes so long. Pity there aren't command line options to provide a subset of the info. I might experiment with this. Maybe prune the output of the command a bit further and set an environment variable, assuming I can read that in DOS too, which will be considerably faster. The `systeminfo` command could then run only infrequently - say hourly. – rossmcm Jan 29 '14 at 13:53
  • You could use another DOS program besides sysinfo (something you install) or try getting the setting from the registry of Turbo Pascal supports that sort of thing. – Rick Sarvas Jan 29 '14 at 14:55
  • Hmmm... @Rick, TP doesn't seem to support the registry. – rossmcm Jan 29 '14 at 21:46
  • Best is to migrate to Free Pascal, it is highly compatible and can access windows resources, and won't get confused by a space in a path. – Marco van de Voort Nov 05 '16 at 13:35