[ANN] DatePicker

1 view
Skip to first unread message

mat...@jondet.org

unread,
Mar 10, 2007, 6:22:56 PM3/10/07
to Ruby on Rails: Spinoffs
Hi all,
for the application i'm developping I needed a datepicker widget. I've
checked the list archives and couldn't find anything prototype-related.

As I'm new to Prototype and Scriptaculous I decided to give a shot at
it. So you can find all the information regarding the datepicker at my
company's website :
http://www.eulerian.com/en/opensource/datepicker-prototype-scriptaculous

Any feedback, comments are welcomed ! Especially on the js code.

Regards,
Mathieu

Andrew Kaspick

unread,
Mar 10, 2007, 6:31:22 PM3/10/07
to rubyonrail...@googlegroups.com
Looks good. Might be giving this one a try in my own app.

Thanks

Gareth Evans

unread,
Mar 10, 2007, 7:53:26 PM3/10/07
to rubyonrail...@googlegroups.com
HI, I was looking at needing to write one of these next week.
I'd be interested in using yours (maybe modified tho, not sure) in my project- is it free to use?
It threw a script error in IE6 btw.
 
Gareth

 

Kjell Bublitz

unread,
Mar 10, 2007, 7:55:00 PM3/10/07
to rubyonrail...@googlegroups.com
Cool thing :)

You should add different Date formats based on locale aswell. Like:
10.03.2007 or 03-10-07
Here is a german translation for your widget:

'de' : [ 'Januar', 'Februar', 'März', 'April', 'Mai',
'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember' ]

'de' : [ 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So' ],

'de' : 'schliessen'


--
Regards, Kjell
www.m3nt0r.de

Kjell Bublitz

unread,
Mar 10, 2007, 7:57:03 PM3/10/07
to rubyonrail...@googlegroups.com
Check out this post from Ben Nolan. Might be interesting for you:
http://www.bennolan.com/articles/2007/02/14/date-prototype-succ


--
Regards, Kjell
www.m3nt0r.de

Gareth Evans

unread,
Mar 10, 2007, 7:59:28 PM3/10/07
to rubyonrail...@googlegroups.com
I think that succ function might need to be added into core, if it isn't already.
 
Gareth

 
On 3/11/07, Kjell Bublitz <m3nt...@gmail.com> wrote:
Check out this post from Ben Nolan. Might be interesting for you:
http://www.bennolan.com/articles/2007/02/14/date-prototype-succ


On 3/11/07, Kjell Bublitz <m3nt...@gmail.com> wrote:
> Cool thing :)
>
> You should add different Date formats based on locale aswell. Like:
> 10.03.2007 or 03-10-07
> Here is a german translation for your widget:
>
> 'de'    : [ 'Januar', 'Februar', 'M�rz', 'April', 'Mai',

Kjell Bublitz

unread,
Mar 10, 2007, 8:01:29 PM3/10/07
to rubyonrail...@googlegroups.com

Gareth Evans

unread,
Mar 10, 2007, 8:03:36 PM3/10/07
to rubyonrail...@googlegroups.com
That's a succ function on the number object, not the date object though?

Kjell Bublitz

unread,
Mar 10, 2007, 8:09:40 PM3/10/07
to rubyonrail...@googlegroups.com
You are right. i misunderstood. sorry.


--
Regards, Kjell
www.m3nt0r.de

mat...@jondet.org

unread,
Mar 10, 2007, 8:19:49 PM3/10/07
to rubyonrail...@googlegroups.com
Kjell Bublitz wrote:
> Cool thing :)

Thanks !

> You should add different Date formats based on locale aswell. Like:
> 10.03.2007 or 03-10-07

This is already handled, if we are in english locale the mm-dd-yyyy
format is used, dd-mm-yyyy is used otherwise.

> Here is a german translation for your widget:
>

> 'de' : [ 'Januar', 'Februar', 'M�rz', 'April', 'Mai',


> 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember' ]
>
> 'de' : [ 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa', 'So' ],
>
> 'de' : 'schliessen'

Thanks, I'll integrate it in a future release.


Mathieu

mat...@jondet.org

unread,
Mar 10, 2007, 8:23:17 PM3/10/07
to rubyonrail...@googlegroups.com
mat...@jondet.org wrote:
>> You should add different Date formats based on locale aswell. Like:
>> 10.03.2007 or 03-10-07
>
> This is already handled, if we are in english locale the mm-dd-yyyy
> format is used, dd-mm-yyyy is used otherwise.

Answering too fast, I do handle the case of days and switching if we are
in english, but do not handle the case of the date separator : . or -,
it's only / right now.

I'll add in a future release.

Thanks.

Mathieu

mat...@jondet.org

unread,
Mar 10, 2007, 8:24:02 PM3/10/07
to rubyonrail...@googlegroups.com
Gareth Evans wrote:
> HI, I was looking at needing to write one of these next week.
> I'd be interested in using yours (maybe modified tho, not sure) in my
> project- is it free to use?

Sure it's free, I should add it to the webpage, but the datepicker.js
file contains a statement indicating it's distributed under the same
termes as Prototype and Scriptaculous, MIT-license.

> It threw a script error in IE6 btw.

Ok, I only tested it under Linux as I don't have a box with IE
available right now. A previous version was working ok under IE7 with no
warnings, maybe I made a mod that triggered something.

Thanks for the report.

Mathieu

Gareth Evans

unread,
Mar 10, 2007, 8:25:27 PM3/10/07
to rubyonrail...@googlegroups.com
yeah was 'null is null or not an object' or something like that...
May be fixed in 1.5.1 rc1

 
On 3/11/07, mat...@jondet.org <mat...@jondet.org> wrote:

Gareth Evans

unread,
Mar 10, 2007, 8:25:51 PM3/10/07
to rubyonrail...@googlegroups.com
I will debug on monday if I get time (sunday 2.25 now)

On 3/11/07, Gareth Evans <agr...@gmail.com> wrote:

RobG

unread,
Mar 10, 2007, 11:25:51 PM3/10/07
to Ruby on Rails: Spinoffs

On Mar 11, 12:19 pm, "math...@jondet.org" <math...@jondet.org> wrote:
> Kjell Bublitz wrote:
> > Cool thing :)
>
> Thanks !
>
> > You should add different Date formats based on locale aswell. Like:
> > 10.03.2007 or 03-10-07
>
> This is already handled, if we are in english locale the mm-dd-yyyy
> format is used, dd-mm-yyyy is used otherwise.

English is not a locale, it is a language spoken in a great many
locales. It is not reasonable to expect that someone using English
will require a date format that is specific to a particular country
that happens to speak English.

The ISO date standard is the place to start for international date
formats:

<URL: http://www.iso.org/iso/en/prods-services/popstds/datesandtime.html
>


--
Rob

Deco Rior

unread,
Mar 11, 2007, 11:45:22 AM3/11/07
to rubyonrail...@googlegroups.com
A few items:

Personally, I think there are two concerns

The value shown to the user:

This should be the localized value

And the ISO value commonly:

YYYY-MM-DD

We have tried using the ISO value for our customers, but they really
don't like it. But it makes sense to standardize the passed value.

Secondly,Another calendar is spinelz.org

Lastly, the biggest problem I have had with calendars is having their
styles be independent. So many calendars are great until incorporated
into a main page where there are css style classes.

I am looking forward to trying this one!

Great work.

Deco

Gareth Evans

unread,
Mar 11, 2007, 6:02:19 PM3/11/07
to rubyonrail...@googlegroups.com
To get around the concerns of having to specify the locale why don't we specify a date-format string which has a number of replaces performed on it.
That way, you can just specify the return format, aside from the locale. If the users application wants * as a seperator, then they can specify it.
 
For example (this is psudeocode / half vb [for the date stuff] half js [for the prototype stuff])
I may have used hash incorrectly, but you should get the drift
 
placeholders_hash -> { 'MM': month(currentDate), 'YYYY': year(currentdate), 'YY': substr(year(currentdate),2), 'D': day(currentdate) }
formatString = 'D/MM/YYYY'
var outputString = formatString;
placeholders_hash.each(function (key,value) { outputString = replace(outputString,key,value) });
alert(outputString);
 
Then by changing formatString, you can control the order, the parts used, the seperator etc.
You could make it iso compliant by passing YYYY-MM-DD (assuming all of those placeholders were in the hash)
 
Just an idea...
 
Gareth

Mathieu Jondet

unread,
Mar 13, 2007, 12:47:14 PM3/13/07
to rubyonrail...@googlegroups.com
Gareth Evans wrote:
> To get around the concerns of having to specify the locale why don't we
> specify a date-format string which has a number of replaces performed on it.
> That way, you can just specify the return format, aside from the locale.
> If the users application wants * as a seperator, then they can specify it.
>
> For example (this is psudeocode / half vb [for the date stuff] half js
> [for the prototype stuff])
> I may have used hash incorrectly, but you should get the drift
>
> placeholders_hash -> { 'MM': month(currentDate), 'YYYY':
> year(currentdate), 'YY': substr(year(currentdate),2), 'D':
> day(currentdate) }
> formatString = 'D/MM/YYYY'
> var outputString = formatString;
> placeholders_hash.each(function (key,value) {
> outputString = replace(outputString,key,value) });
> alert(outputString);
>
> Then by changing formatString, you can control the order, the parts
> used, the seperator etc.
> You could make it iso compliant by passing YYYY-MM-DD (assuming all of
> those placeholders were in the hash)
>
> Just an idea...


Hi Gareth,
ok, I'll will work on this type of approach to give more power to the
user for formatting the date, thanks for the input.
In the meantime I just released an minor update to the initial release
v0.9.1 :
http://www.eulerian.com/en/opensource/datepicker-prototype-scriptaculous
Here is the ChangeLog :
- replace locale by language (RobG)
- add support for german language (Kjell Bublitz)
- add support for portuguese language
- use Prototype.emptyFunction when clickCallBack not defined, should
fix possible bug with IE and null objects (Gareth Evans)
- some code clean-up using Builder.node

Regards,
Mathieu

Gareth Evans

unread,
Mar 13, 2007, 4:03:47 PM3/13/07
to rubyonrail...@googlegroups.com
While it may be implied, it's also best said:
 
The placeholder hash should contain more than just MM, YYYY and D. It should also contain all the other date part constants- YY for 2 digit year, MMM for short date etc.
There are many different implementations here, you can keep your code tidy by storing the placeholders and the resulting values for each of the calculations in the hash in my earlier example.
 
Feel free to interchange as you see fit, I tried to keep with a scheme
 
m Month as non zero padded number 2
mm Month as a decimal no, zero padded. 02
M Abbreviated month name Feb
MM Full month name February
dd Day as number, zeropadded (08)
d Day of the month (23)
y Day of the year (54)
yy Year without century (98)
yyyy Year with century (1998)
w Weekday (5 (0 is Sunday))
ww Week of year (45)
a Abbreviated day name Fri
A Weekday Name Friday
q Quarter (1)

Fabian Lange

unread,
Mar 13, 2007, 4:19:10 PM3/13/07
to rubyonrail...@googlegroups.com

Hello,

Have you considered aligning it with DHTML calendar?

http://www.dynarch.com/projects/calendar/

when you have adopted what that guy does you get perhaps a bigger client base. I know many projects using it because it does everything what is needed. Especially it has a mechanism for the formatting

 

.: Fabian

 


<br

Colin Mollenhour

unread,
Mar 13, 2007, 6:54:14 PM3/13/07
to rubyonrail...@googlegroups.com
Agreed, DHTML calendar is pretty close to what SQL uses for date formatting, I would suggest sticking to an existing standard rather than creating a new one.

Colin

mat...@jondet.org

unread,
Mar 13, 2007, 7:48:46 PM3/13/07
to rubyonrail...@googlegroups.com
Colin Mollenhour wrote:
> Agreed, DHTML calendar is pretty close to what SQL uses for date
> formatting, I would suggest sticking to an existing standard rather than
> creating a new one.
>
> Colin
>

Hi Colin, Fabian, Gareth,
I couldn't agree more. I'll give a look at what could be used as a way
to provide a consistent API and avoid new (inefficient) stuff.

Regards,
Mathieu

Reply all
Reply to author
Forward
0 new messages