Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Jun 22, 2018 2:07 pm
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: ParseDate problem
PostPosted: Fri Dec 21, 2012 11:24 am 
Offline
User avatar

Joined: Sat Jun 04, 2011 8:29 am
Posts: 387
I have a place where user enters their birthdate... popdown select the month, enter the day, and year. I have a conversion of month to digit so the string created is like "1/1/1950" which is then passed into ParseDate so we can do some date math.

On one customers machine it fails with "invalid birthdate" even though in the error popup it shows "1/1/1950".

Turns out in his Date&Time in System Prefs he had changed the date format on his computer to be of the format: Year-Month-Day or "1950/1/1" so I think that preference change is barfing my ParseDate.

Sooooooo.... how do I detect such a system change? i.e. what should I do differently in my code?

_________________
Currently using:
Windows XP Pro SP3
Real Studio 2011 Release 4.3 Enterprise
and
Mac OS 10.7.4
Real Studio 2011 Release 4.3 Enterprise
(finally also compiled on Mac)


Top
 Profile  
Reply with quote  
 Post subject: Re: ParseDate problem
PostPosted: Fri Dec 21, 2012 12:12 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
If you have the individual values, why would you need to use ParseDate? Use the Date constructor that accepts month/day/year values.

year = //year entered by user
month = // month entered by user
day = //day entered by user
dim birthdate as Date = New Date(year, month, day)


Top
 Profile  
Reply with quote  
 Post subject: Re: ParseDate problem
PostPosted: Fri Dec 21, 2012 3:24 pm 
Offline
User avatar

Joined: Fri Jun 05, 2009 11:50 am
Posts: 348
Location: Hamburg, Germany
Had the same problem few years ago

Basic idea:

create a date object setting it to a known date (e.g. 1986-12-02)
get date.shortdate (returns a string of the known date according to users local settings (e.g. 12/02/1986 or 02/12/1986)
identify position of year, month, day in the string (as you know what is what)
put user entered date into a string of the same order as the date.shortdate format
parse the date to a dateobject.

_________________
Best regards

Stefan

Mac OSX Mountain Lion (latest Release) on a MacBook Pro 2.66 GHz Intel Core i7/ RB Professional 2011 Release 3


Top
 Profile  
Reply with quote  
 Post subject: Re: ParseDate problem
PostPosted: Fri Dec 21, 2012 3:59 pm 
Offline

Joined: Fri Jan 06, 2006 3:21 pm
Posts: 12388
Location: Portland, OR USA
Quote:
put user entered date into a string of the same order as the date.shortdate format
parse the date to a dateobject.

But why? If you already know the month/day/year, why would you ever use ParseDate?


Top
 Profile  
Reply with quote  
 Post subject: Re: ParseDate problem
PostPosted: Fri Dec 21, 2012 4:27 pm 
Offline
User avatar

Joined: Fri Jun 05, 2009 11:50 am
Posts: 348
Location: Hamburg, Germany
timhare wrote:
But why? If you already know the month/day/year, why would you ever use ParseDate?



I won't, but in cases where one doesn't have the knowledge about month/day/year or need to know for whatever reason the local user date settings the idea would work

_________________
Best regards

Stefan

Mac OSX Mountain Lion (latest Release) on a MacBook Pro 2.66 GHz Intel Core i7/ RB Professional 2011 Release 3


Top
 Profile  
Reply with quote  
 Post subject: Re: ParseDate problem
PostPosted: Tue Jan 01, 2013 8:28 pm 
Offline
User avatar

Joined: Sat Jun 04, 2011 8:29 am
Posts: 387
timhare.... thanks once again....for saving my hide...

and Happy New year!

:P

_________________
Currently using:
Windows XP Pro SP3
Real Studio 2011 Release 4.3 Enterprise
and
Mac OS 10.7.4
Real Studio 2011 Release 4.3 Enterprise
(finally also compiled on Mac)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 5 hours


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

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group