**** BEGIN LOGGING AT Mon Jan 28 03:00:00 2013 Jan 28 19:56:40 pancake: Did you get your answer to the scrollTo without animation? Jan 28 21:51:23 * phil_bw wanders by Jan 28 21:51:25 anyone around? Jan 28 21:51:39 I'm here, idling mostly Jan 28 21:51:52 I need a little help with some JS date stuff Jan 28 21:52:03 here's the code: http://pastie.org/5917985 Jan 28 21:52:17 I'm simply trying to increment date values by month Jan 28 21:52:36 ds should = the first of the prev month, de should = the last day of the prev month Jan 28 21:54:39 it works properly the first time going from JAN to DEC, then going from DEC to NOV the first date changes properly but the second one jumps to OCT Jan 28 21:57:02 it looks like it's breaking between lines 15 and 18 Jan 28 21:57:21 line 18 in particular shouldn't be saying Dec 01, right? Jan 28 21:57:33 correct Jan 28 21:57:54 should say Nov 30 Jan 28 21:59:22 I'm wondering, and I don't know this for sure, if it's because of number of days in the months Jan 28 21:59:54 that was my initial thought but that's how I seen online I was supposed to do it Jan 28 22:00:48 and getMonth() just returns numbers from 0 to 11 Jan 28 22:00:52 so, that shouldn't matter Jan 28 22:01:34 what happens if you do setMonth() on a negative number? Jan 28 22:01:50 hm Jan 28 22:01:51 dunno Jan 28 22:01:53 lemme check Jan 28 22:02:45 the docs says -1 goes to "the last month of the previous year" Jan 28 22:02:51 but I'm curious about -2, etc. Jan 28 22:03:16 yeah and as you can see it's going from Jan 2013 to Dec 2012 properly Jan 28 22:03:19 yes Jan 28 22:03:22 once in 2012 it all goes to hell Jan 28 22:03:56 the w3c code seems to just work fine for negative numbers below 0 Jan 28 22:04:51 brb Jan 28 22:05:06 k Jan 28 22:10:07 B R B T O O Jan 28 22:12:47 I'm back Jan 28 22:14:40 one sec Jan 28 22:15:25 space bar malfunction... Jan 28 22:16:00 how are you manipulating de? Jan 28 22:19:26 one more sec, gotta get things reloaded, whole computer went to hell... Jan 28 22:21:50 ok, so what do you mean how am I manipulating it? Jan 28 22:22:28 how do you get it to the point of having the last date of a month? Jan 28 22:22:56 130 osd = this.get("sel_sdate"); Jan 28 22:22:56 131 sd = new Date(osd.getFullYear(), osd.getMonth(), 1); Jan 28 22:22:56 132 ed = new Date(osd.getFullYear(), osd.getMonth()+1, 0); Jan 28 22:23:32 ds = sd and de = ed Jan 28 22:24:49 hm Jan 28 22:24:51 hmmm Jan 28 22:25:03 I wonder why I did +1 on one of them and not the other Jan 28 22:26:18 I'm also wondering about the 0 Jan 28 22:26:34 you likely don't need the +1 on the second one Jan 28 22:26:37 would be my guess Jan 28 22:26:49 hm Jan 28 22:27:13 unless you're trying to do +1, and then have it roll backwards Jan 28 22:27:15 I changed it to not have the +1 and now it increments the months properly but the last day is showing as the first Jan 28 22:27:27 setting day to 0 should set to last day Jan 28 22:27:35 really? Jan 28 22:27:40 oh yes I think that's why Jan 28 22:28:00 * phil_bw doesn't know JS date functions all that well... Jan 28 22:29:22 ok, that's the issue Jan 28 22:29:44 0 sets it to the last day, but upon modifying the month, it just keeps the value Jan 28 22:29:55 if the value is too big for the month that we're talking about, it reverts to 1 Jan 28 22:30:32 so, for instance: d = new Date(2012, 9, 0) gets you Sept. 30 Jan 28 22:30:33 I see Jan 28 22:30:57 right Jan 28 22:30:57 but if you then do d.setMonth(d.getMonth()-7) gets you Feb. 1 Jan 28 22:31:16 because Feb has fewer days than Sept. Jan 28 22:31:30 but if you'd done d.getMonth()+1, you'd get Oct. 30 Jan 28 22:31:33 not Oct. 31 Jan 28 22:31:48 makes sense Jan 28 22:31:56 absolutely not Jan 28 22:31:56 why can't JS be as smart as PHP with dates Jan 28 22:32:16 why you guys making me think Jan 28 22:32:17 it hurts! Jan 28 22:32:21 phil_bw: to make this more difficult, it doesn't look like there's a setDay() Jan 28 22:32:29 fxspec06, shouldn't you be in bed? Jan 28 22:32:40 summatusmentis, there is, its' setDate() Jan 28 22:32:50 phil_bw, i had to eat, and thus my eyes were averted towards the activity in here Jan 28 22:32:51 my day incrementer works fine Jan 28 22:33:14 i'm debating whether to do my c++ homework or to nap before the bruins game Jan 28 22:33:17 oh, set Date() Jan 28 22:33:23 but getDay() Jan 28 22:33:25 that's absured Jan 28 22:33:27 absurd* Jan 28 22:33:40 ds.setDate(ds.getDate()-1); Jan 28 22:33:51 that sets the prev day and jumps between months correctly Jan 28 22:34:09 fxspec06, or even better you can help me fix my date issue :P Jan 28 22:35:52 i don't have any experience setting dates, only getting them. and that rarely happens IRL Jan 28 22:36:01 lol... Jan 28 22:36:13 phil_bw: so, in the code you pastebinned, I'd use setDate(0) for de, instead of setMonth(getMonth()-1) Jan 28 22:36:31 oh wait, that's not quite right Jan 28 22:37:32 setDate(0) gets you the last day of the previous month Jan 28 22:37:48 hm Jan 28 22:38:29 lemme try it Jan 28 22:38:41 yes, so, don't decrement the month, just setDate(0); Jan 28 22:38:48 that'll do what you want Jan 28 22:39:22 fixed Jan 28 22:39:27 now to go the other direction :) Jan 28 22:40:43 I'd do setDate(0)+1 Jan 28 22:40:49 to wrap the other way Jan 28 22:44:45 doesn't work right Jan 28 22:45:21 really? Jan 28 22:45:49 I have an idea Jan 28 22:46:41 oh wait that won't work Jan 28 22:47:40 \oh wait, shouldn't setDate(getDate()+1) just do the right thing? Jan 28 22:48:53 get date not defined... Jan 28 22:50:28 is the object you're calling getDate() on a Date object? Jan 28 22:50:52 yes Jan 28 22:51:32 weird Jan 28 22:51:37 well, good luck, I'm gonna head home Jan 28 22:51:54 thanks for all the help, I appreciate it Jan 28 23:31:10 So I asked for some help in #javascript and they unanimously suggested using a library to deal with dates, so that's what I did **** ENDING LOGGING AT Tue Jan 29 02:59:58 2013