Live data from Hacker News

Pickadate.js

github.com

121–130 of 130 posts

Re: Pickadate.js

#121
post #14

Does December work? :3

That was my first question too! So I tested it and it comes with December. Actually, it has all of the 12 months - no sacrifices there. Amazing stuff.

Phew, thanks for this. Now I can sleep at night again.

Re: Pickadate.js

#123
post #2

From the demos it appears that this doesn't have keyboard support. That seems like a major drawback from an accessibility standpoint. It does look nice and easy otherwise, though.

I thought that when I use it as a textbox it would automatically auto complete and hint a month, or dynamically show calendar selecting date while I'm typing, it did neither of those things. Also I haven't looked at the API that hard, but from the examples it looks like it only supports american way of setting the date i.e. DD/Month/YYYY Update: another big omission, I can select year only by scrolling through it mon…

Isn't the American way Month/Date/Year?

Re: Pickadate.js

#124
post #52

Earlier quoted context omitted.

These pair nicely: http://dojotoolkit.org/reference-guide/1.8/dijit/form/DateTe...

I'm still completely baffled that Dojo doesn't seem to get as much love as it should.

It has a reputation for bad docs etc... But they corrected a lot of that recently

Re: Pickadate.js

#125

A few random comments... This value is not what it says: SECONDS_IN_DAY = 86400000, That's the number of milliseconds in a day. Instead of a magic precalculated number, why not create all the relevant constants so the values become perfectly clear: HOURS_IN_DAY = 24, MINUTES_IN_DAY = HOURS_IN_DAY * 60, SECONDS_IN_DAY = MINUTES_IN_DAY * 60, MILLISECONDS_IN_DAY = SECONDS_IN_DAY * 1000, Personally, I find these kinds of…

Just a followup on my "amazing and scary" comment. The "amazing" part is a genuine compliment: you found a pattern in the number of days in each month that I never noticed (the 'flip' trick). Being able to see these kinds of patterns and take advantage of them is an invaluable skill in programming.

The problem here, of course, is that it makes the code a lot harder to understand. To understand and verify the function, I'd start by writing out a table of the days in each month while reciting the "30 days hath September" rhyme. :-) Then I'd have to go through all the the flip and non-flip cases in the code and compare against my table.

Let's imagine that JavaScript didn't have convenient date calculations so we couldn't use the updated function I posted above. If that were the case, what would be a simpler way to code the function? Just use the table of months directly. After all, there are only 12 months to deal with, so it's very simple:

    getCountDays: function( year, month ) {
        var monthDays = [
            31,  0, 31, 30, 31, 30,
            31, 31, 30, 31, 30, 31
        ];
        return monthDays[month] || getFebDays( year );
    },
where getFebDays() handles all the special cases for leap years ( /4, /100, /400, etc.)

Now, with the exception of February, it's trivial to see at a glance if the function is correct.

Re: Pickadate.js

#126
post #100

Earlier quoted context omitted.

Please, never use the Dojo Toolkit. I was forced to use it on a project and working with it was reinventing the wheel while pulling out hair. It was overly complicated for something that needed to be straightforward and simple.

Amen to that. The doc for it sucks too (not that there's enough there, but most doc for it found by google et al is obsolete/deprecated. And last but not least... the plugin ecosystem for dojo sucks even worse, and whatever widgets/dijits actually exist for it, usually look like @ss. The only one who seems to be committed to dojo is...IBM.

ESRI the top worldwide provider of GIS software is also sold on Dojo and Dijits. I agree that their digits are uglier than Android Cupcake. I have had to use Dojo on several projects now and I also agree on how abysmal their docs are. They provide tiny little code snippets but aren't even clear of the context. "Ok, fine... where do I PUT this snip... isn't this a TUTORIAL???!!??" I've been much happier with the look and feel of ExtJS but its documentation is even worse.

Re: Pickadate.js

#127
post #54
post #51

Earlier quoted context omitted.

There you go - this will make your life easier then: http://dojotoolkit.org/reference-guide/1.8/dijit/form.html#d...

Too bulky in my opinion. I don't need 90 percent of the things in that sdk.

I don't really like Dojo, but their system is so modular, you don't have to include 90% of stuff. Kinda like jQuery-ui, you can choose not to include all the other cruft.

Now with Dojo AMD (1.7+) it's even better and cleaner. You only require what you need and then build.

Re: Pickadate.js

#128

A few random comments... This value is not what it says: SECONDS_IN_DAY = 86400000, That's the number of milliseconds in a day. Instead of a magic precalculated number, why not create all the relevant constants so the values become perfectly clear: HOURS_IN_DAY = 24, MINUTES_IN_DAY = HOURS_IN_DAY * 60, SECONDS_IN_DAY = MINUTES_IN_DAY * 60, MILLISECONDS_IN_DAY = SECONDS_IN_DAY * 1000, Personally, I find these kinds of…

Ha! I was thinking about my version of getCountDays() and realized there was probably a bug in it. Did anyone else see it?

  getCountDays( 2012, 2 )  // Daylight time began March 11
  30  // oops
new Date(year,month,...) uses local time, so the day will be an hour longer or shorter when the time changes.

A quick and dirty fix would be to use Math.round instead of Math.floor:

    getCountDays = function( year, month ) {
        var msInMonth = new Date(year,month+1) - new Date(year,month);
        return Math.round( msInMonth / MILLISECONDS_IN_DAY );
    },
And maybe better to use UTC? (I'd stick with Math.round at the same time.)

    getCountDays = function( year, month ) {
        var msInMonth = Date.UTC(year,month+1) - Date.UTC(year,month);
        return Math.round( msInMonth / MILLISECONDS_IN_DAY );
    },

Re: Pickadate.js

#129
post #86

Earlier quoted context omitted.

But how can you tell if the browser has support for the native picker? You can't. That's what I was wondering. If there were a way, it'd be pretty awesome to use a library like this as a polyfill rather than as a separate thing you attach to text inputs.

You can. Modernizr will tell you if the browser supports the native picker. http://modernizr.com/

It doesn't tell that. From Modernizr wiki[0]: "webforms UI: datepicker, colorpicker UIs cannot be detected, only the associated constraint validation"

[0]: https://github.com/Modernizr/Modernizr/wiki/Undetectables

Post reply on HN