engineer9090909090909090 / jquery-datepicker

Automatically exported from code.google.com/p/jquery-datepicker
0 stars 0 forks source link

Comparing two dates in your overloaded Date object #335

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
Hi,
I need some method in order to compare two dates, but I can't use standard Date 
object because you have oveloaded it. Can you give me some example of comparing 
two dates?
Thank you

Original issue reported on code.google.com by vicmo...@gmail.com on 23 Jan 2012 at 4:03

GoogleCodeExporter commented 8 years ago
There should be nothing stopping you using standard methods on the Date object, 
I just add some methods to it's prototype. What methods aren't working for you?

Original comment by kelvin.l...@gmail.com on 23 Jan 2012 at 4:09

GoogleCodeExporter commented 8 years ago
Date d1 = new Date(string1);
Date d2 = new Date(string2);
if (d1 > d2)....

Original comment by vicmo...@gmail.com on 23 Jan 2012 at 4:11

GoogleCodeExporter commented 8 years ago
It seems that something in date.js is preventing new Date(string) from 
working... From a quick look I'm not sure what...

You could try Date.fromString() or Date.parse() instead of the "new" method?

Original comment by kelvin.l...@gmail.com on 23 Jan 2012 at 4:43

GoogleCodeExporter commented 8 years ago
Actually, there doesn't appear to be any issue:

http://jsfiddle.net/HfMrb/1/

For some reason when I first tested in Firebug on my demo site something weird 
seemed to happen but in that clean example as you can see everything works as 
expected...

Original comment by kelvin.l...@gmail.com on 23 Jan 2012 at 6:42

GoogleCodeExporter commented 8 years ago
Ok, thanks. Date.fromString() helped. By the way, you can add some compare 
method in your date.js library.

Original comment by vicmo...@gmail.com on 24 Jan 2012 at 5:23

GoogleCodeExporter commented 8 years ago
About comment#4: T think the problem with date format. You used standard 
format, but I tested it with "dd/MM/yyyy" format.

Original comment by vicmo...@gmail.com on 24 Jan 2012 at 5:25

GoogleCodeExporter commented 8 years ago
By the way, does your plugin have any way to select specific date (on calendar) 
without calling dateSelecgted event? Thank you

Original comment by vicmo...@gmail.com on 24 Jan 2012 at 6:40