Discussion:
accepting date in dd/mm/yyyy format
(too old to reply)
Aby Mathew
2004-02-20 04:53:03 UTC
Permalink
Hi

I want to accept date in dd/mm/yyyy format but after two days am still not
able to do it. I am able to display date in this format but in the case of
accepting a date when the focus comes on the accepting field the date format
turns to mm/dd/yyyy. Somebody help me with this. It may seem simple but help
would be highly appreciated.

Aby
Volker Zink
2004-02-20 08:04:07 UTC
Permalink
Hello,

i assume you are using an InputField. You can specify the format, but it
uses this format only if it has NOT the focus, else it uses the format
of the Locale. If i remember this case correct, then the reason is the
method InputFieldView>>shouldUseFullFormating.

When writing a calendar widget i wrote a subclass, which returns always
true. You can't do that if you want to just use an InputField.
Another solution would be to change the
PrintConverter>>initFor...-Methods. There are the toPrint- and
toRead-Blocks which are used for converting. Maybe you want to write
your own PrintConverter.

Sadly i don't know a solution where you just have to change a setting.

Hope this helps.

Volker
Post by Aby Mathew
Hi
I want to accept date in dd/mm/yyyy format but after two days am still not
able to do it. I am able to display date in this format but in the case of
accepting a date when the focus comes on the accepting field the date format
turns to mm/dd/yyyy. Somebody help me with this. It may seem simple but help
would be highly appreciated.
Aby
Aby Mathew
2004-02-20 09:37:16 UTC
Permalink
Thanks for that. I am not much of an expert in Smalltalk so changing methods
or classes will be a bit too much. Is there any other way out.

Aby
Post by Volker Zink
Hello,
i assume you are using an InputField. You can specify the format, but it
uses this format only if it has NOT the focus, else it uses the format
of the Locale. If i remember this case correct, then the reason is the
method InputFieldView>>shouldUseFullFormating.
When writing a calendar widget i wrote a subclass, which returns always
true. You can't do that if you want to just use an InputField.
Another solution would be to change the
PrintConverter>>initFor...-Methods. There are the toPrint- and
toRead-Blocks which are used for converting. Maybe you want to write
your own PrintConverter.
Sadly i don't know a solution where you just have to change a setting.
Hope this helps.
Volker
Post by Aby Mathew
Hi
I want to accept date in dd/mm/yyyy format but after two days am still not
able to do it. I am able to display date in this format but in the case of
accepting a date when the focus comes on the accepting field the date format
turns to mm/dd/yyyy. Somebody help me with this. It may seem simple but help
would be highly appreciated.
Aby
Magnus Jakt
2004-02-20 09:52:12 UTC
Permalink
You want to read the Internationalization Guide (InternationalGuide.pdf), which will tell you how (you want to look at Locale and the methods available there).

However, I found that I had some sort of problem with resetting the Locale on my system (I forgot what, maybe some environment variable was wrong or something), so I ended up changing the default locale to print dates the way I wanted. In particular you want to look at the TimestampPrintPolicy class and its related methods. I just choose one of the initialize methods that were closest to what I wanted, created a new one with my changes and had that be called on Locale initialization.

Hope this helps,

Magnus
Post by Aby Mathew
Hi
I want to accept date in dd/mm/yyyy format but after two days am still not
able to do it. I am able to display date in this format but in the case of
accepting a date when the focus comes on the accepting field the date format
turns to mm/dd/yyyy. Somebody help me with this. It may seem simple but help
would be highly appreciated.
Aby
--
Magnus Jakt
(Remove the obvious from the return address when replying)
Aby Mathew
2004-02-20 11:05:05 UTC
Permalink
For the time being I could not change the locale as I want but I have found
another way. Is it a good thing to accept the date as a string and then
interchange the month and date and then pass it to the database. Its a bit
crude but it works. Anybody with any other ideas.

Aby
Post by Magnus Jakt
You want to read the Internationalization Guide (InternationalGuide.pdf),
which will tell you how (you want to look at Locale and the methods
available there).
Post by Magnus Jakt
However, I found that I had some sort of problem with resetting the Locale
on my system (I forgot what, maybe some environment variable was wrong or
something), so I ended up changing the default locale to print dates the way
I wanted. In particular you want to look at the TimestampPrintPolicy class
and its related methods. I just choose one of the initialize methods that
were closest to what I wanted, created a new one with my changes and had
that be called on Locale initialization.
Post by Magnus Jakt
Hope this helps,
Magnus
Post by Aby Mathew
Hi
I want to accept date in dd/mm/yyyy format but after two days am still not
able to do it. I am able to display date in this format but in the case of
accepting a date when the focus comes on the accepting field the date format
turns to mm/dd/yyyy. Somebody help me with this. It may seem simple but help
would be highly appreciated.
Aby
--
Magnus Jakt
(Remove the obvious from the return address when replying)
Thomas Gagné
2004-02-21 12:40:01 UTC
Permalink
I'd avoid playing around with the string. That's a lot of work.

An example I read somewhere talked about how the mm/dd/yyyy format is
instantiated easily using:

(Locale named: #C) readDateFrom: aReadStream

Where aReadStream would be created by sending #readStream to your date
string like:

(Locale named: #C) readDateFrom: '02/21/2004' readStream

I know your's isn't #C, but I don't know which it might be. To find out
which locales were loaded into my image:

Locale allLocaleObjects

But if you know how your date are coming in and want them to be d/m/y,
you could just do:

(Locale named: #'nl_D.ISO8859-1') readDateFrom: '14/11/2003' readStream

I'm guessing nl is Netherlands. The above returns 'November 14, 2003'
when sent #longPrintString.
Post by Aby Mathew
For the time being I could not change the locale as I want but I have found
another way. Is it a good thing to accept the date as a string and then
interchange the month and date and then pass it to the database. Its a bit
crude but it works. Anybody with any other ideas.
Aby
Post by Magnus Jakt
You want to read the Internationalization Guide (InternationalGuide.pdf),
which will tell you how (you want to look at Locale and the methods
available there).
Post by Magnus Jakt
However, I found that I had some sort of problem with resetting the Locale
on my system (I forgot what, maybe some environment variable was wrong or
something), so I ended up changing the default locale to print dates the way
I wanted. In particular you want to look at the TimestampPrintPolicy class
and its related methods. I just choose one of the initialize methods that
were closest to what I wanted, created a new one with my changes and had
that be called on Locale initialization.
Post by Magnus Jakt
Hope this helps,
Magnus
Post by Aby Mathew
Hi
I want to accept date in dd/mm/yyyy format but after two days am still
not
Post by Magnus Jakt
Post by Aby Mathew
able to do it. I am able to display date in this format but in the case
of
Post by Magnus Jakt
Post by Aby Mathew
accepting a date when the focus comes on the accepting field the date
format
Post by Magnus Jakt
Post by Aby Mathew
turns to mm/dd/yyyy. Somebody help me with this. It may seem simple but
help
Post by Magnus Jakt
Post by Aby Mathew
would be highly appreciated.
Aby
--
Magnus Jakt
(Remove the obvious from the return address when replying)
--
.tom
remove email address' dashes for replies
opensource middleware at <http://isectd.sourceforge.net>
http://gagne.homedns.org
lijimaymol
2014-03-22 21:27:32 UTC
Permalink
I also face this same issue. How did you correct that?
Sreenath G K
2014-05-12 07:19:10 UTC
Permalink
Hi Aby Chetta,

just happened to see this post. Is that on website or application side ?

Let me know.

Regards,
Sreenath
9745248322
Post by Aby Mathew
Hi
I want to accept date in dd/mm/yyyy format but after two days am still not
able to do it. I am able to display date in this format but in the case of
accepting a date when the focus comes on the accepting field the date format
turns to mm/dd/yyyy. Somebody help me with this. It may seem simple but help
would be highly appreciated.
Aby
Aby Mathew
2014-06-18 12:38:58 UTC
Permalink
That was a post of 2004 and I don't even remember the context now..

Rgds

Aby
Post by Sreenath G K
Hi Aby Chetta,
just happened to see this post. Is that on website or application side ?
Let me know.
Regards,
Sreenath
9745248322
Post by Aby Mathew
Hi
I want to accept date in dd/mm/yyyy format but after two days am still not
able to do it. I am able to display date in this format but in the case of
accepting a date when the focus comes on the accepting field the date format
turns to mm/dd/yyyy. Somebody help me with this. It may seem simple but help
would be highly appreciated.
Aby
Continue reading on narkive:
Loading...