Real Software Forums
http://forums.realsoftware.com/

Program displays incorrect date format in Linux
http://forums.realsoftware.com/viewtopic.php?f=8&t=32525
Page 1 of 1

Author:  grechcj [ Mon Feb 15, 2010 3:34 pm ]
Post subject:  Program displays incorrect date format in Linux

My program runs fine on Mac and Windows but the Linux version displays dates in US format mm/dd/yyyy instead of Australian (UK) dd/mm/yyyy
I am running several Linux distros inside Virtualbox for Windows - Ubuntu, Mandriva ... and I have checked the control panel settings to ensure the system is set to the Australian format. I have also checked VirtualBox settings.
But the program still displays the month before the day. Also Functions such as parsedate return an error with dates that would be invalid in US eg. "22/1/2010".

If I can't get to the bottom of this is there a function which will retrieve the country settings from the OS so I can conditionally format the date myself?

Author:  grechcj [ Tue Feb 23, 2010 3:59 pm ]
Post subject:  Re: Program displays incorrect date format in Linux

Could someone please have a look at this for me I'm stuck. If it happens on all machines it's a major bug.
If you have Linux can you please temporarily change your Date settings to UK (dd/mm/yyyy) and try a little proceedure -

Dim todaysDate as Date
todaysDate = new Date
msgbox str(todaysDate)

Author:  Steve Garman [ Tue Feb 23, 2010 4:19 pm ]
Post subject:  Re: Program displays incorrect date format in Linux

Sorry, not currently on Linux but I always use
msgbox todaysDate.ShortDate

Author:  grechcj [ Wed Feb 24, 2010 2:19 am ]
Post subject:  Re: Program displays incorrect date format in Linux

In vb converting a date to a string is an easy way of applying the correct regional date format (hence the long approach).
Are you saying the shortdate property does the same, or are you just showing me a way to shorten my code.

Author:  timhare [ Wed Feb 24, 2010 2:50 am ]
Post subject:  Re: Program displays incorrect date format in Linux

Yes, the ShortDate property is what you should use. It obeys the system settings. Using Str() to convert a date is undefined.

Author:  grechcj [ Wed Feb 24, 2010 4:35 am ]
Post subject:  Re: Program displays incorrect date format in Linux

timhare wrote:
Yes, the ShortDate property is what you should use. It obeys the system settings. Using Str() to convert a date is undefined.


Okay that sounds good but my program is currently throwing an error when I attempt to parse the date entered in a text field eg. (UK regional format - dd/mm/yyyy) 24/02/2010
It returns not a valid date when in fact it is.

I can't convert it to a date therefore I can't use the shortdate property.

Since this only happens under Linux the only solution I can think of is getting the systems country setting either automatically (??) or as part of the program setup options then doing messy string extractions for UK format countries (anyone got a list of them?) to extract day and month from the users text input so I can build a date string in US format for storage in my database. Then I have to convert it back to display it correctly on UK systems.

Very messy and fraught with danger, especially when there is no easy way to check that the string is a proper date in the first place.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/