Javascript and Dates
-
I want to commit a crime that may put me on death row. 1. Months start at 0. January is 0. WTF. I realize this is probably because whatever sh*t for brains wrote Date was thinking, oh, month should be an index so month[0] == 'January". Idiot. 2. Changes date even though I'm only providing a date, so the time defaults to 0 Zulu, which means that at the moment, today is yesterday somewhere in the world, so all my dates are back one day. Same UI later in the day shows the correct date. :mad: Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!
So Marc, tell me, when's the last time you got laid?
Jeremy Falcon
-
I want to commit a crime that may put me on death row. 1. Months start at 0. January is 0. WTF. I realize this is probably because whatever sh*t for brains wrote Date was thinking, oh, month should be an index so month[0] == 'January". Idiot. 2. Changes date even though I'm only providing a date, so the time defaults to 0 Zulu, which means that at the moment, today is yesterday somewhere in the world, so all my dates are back one day. Same UI later in the day shows the correct date. :mad: Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!
Hahaha. As serendipity has it, I just last night bought JavaScript: The Good Parts. I wonder what Crockford's going to make of The Date Thing.
No object is so beautiful that, under certain conditions, it will not look ugly. - Oscar Wilde
-
I want to commit a crime that may put me on death row. 1. Months start at 0. January is 0. WTF. I realize this is probably because whatever sh*t for brains wrote Date was thinking, oh, month should be an index so month[0] == 'January". Idiot. 2. Changes date even though I'm only providing a date, so the time defaults to 0 Zulu, which means that at the moment, today is yesterday somewhere in the world, so all my dates are back one day. Same UI later in the day shows the correct date. :mad: Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!
Not that I use it, but I thought arrays in VB were 1-based, and people hate it for that. Well, that and many other reasons. Are you advocating we should follow the VB model? :-) month[0] being January makes sense to me. That said, an enum defining month names starting at 1 also make sense to me. I see no way of ever reconciliating these sort of idiosyncrasies, unfortunately.
-
So Marc, tell me, when's the last time you got laid?
Jeremy Falcon
Jeremy Falcon wrote:
So Marc, tell me, when's the last time you got laid?
Recently. ;) No need to be more explicit, haha. Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!
-
Jeremy Falcon wrote:
So Marc, tell me, when's the last time you got laid?
Recently. ;) No need to be more explicit, haha. Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!
Touché!
Jeremy Falcon
-
I want to commit a crime that may put me on death row. 1. Months start at 0. January is 0. WTF. I realize this is probably because whatever sh*t for brains wrote Date was thinking, oh, month should be an index so month[0] == 'January". Idiot. 2. Changes date even though I'm only providing a date, so the time defaults to 0 Zulu, which means that at the moment, today is yesterday somewhere in the world, so all my dates are back one day. Same UI later in the day shows the correct date. :mad: Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!
The method is deprecated, but try mydate.getYear() sometime ;) :doh:
TTFN - Kent
-
Not that I use it, but I thought arrays in VB were 1-based, and people hate it for that. Well, that and many other reasons. Are you advocating we should follow the VB model? :-) month[0] being January makes sense to me. That said, an enum defining month names starting at 1 also make sense to me. I see no way of ever reconciliating these sort of idiosyncrasies, unfortunately.
That would be somewhat OK, if it were consistent, in which case the first day of the month would be day 0, and the first year of a century would be 0 + the century. But it is not consistent and, by convention, months and days are already numbers starting with 1. Why confuse things just because you are a programmer who likes to put the months in an array starting with a zero offset? In that case, that offset should be calculated and used internally, not by forcing everyone else to add 1 to the month everywhere it is used. I agree with the poster that some common standards were made by people exhibiting ID-10-T errors.
-
I want to commit a crime that may put me on death row. 1. Months start at 0. January is 0. WTF. I realize this is probably because whatever sh*t for brains wrote Date was thinking, oh, month should be an index so month[0] == 'January". Idiot. 2. Changes date even though I'm only providing a date, so the time defaults to 0 Zulu, which means that at the moment, today is yesterday somewhere in the world, so all my dates are back one day. Same UI later in the day shows the correct date. :mad: Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!
-
I want to commit a crime that may put me on death row. 1. Months start at 0. January is 0. WTF. I realize this is probably because whatever sh*t for brains wrote Date was thinking, oh, month should be an index so month[0] == 'January". Idiot. 2. Changes date even though I'm only providing a date, so the time defaults to 0 Zulu, which means that at the moment, today is yesterday somewhere in the world, so all my dates are back one day. Same UI later in the day shows the correct date. :mad: Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!
-
Perhaps you don't like zero-base array. Perhaps Pascal/Delphi suits you better? It is the only language with 1 base array I know off.:cool:
Isn't BASIC 1-index too? And I'm quite happy with 0-based arrays. However, a month number is not an index. It is a human-readable abstraction starting with "1". Therefore, when I ask for the month in Javascript, I do NOT expect to get 0 for January. By Javascript's logic, the first day of the month should be 0!!!! Marc
Imperative to Functional Programming Succinctly Contributors Wanted for Higher Order Programming Project!
-
That would be somewhat OK, if it were consistent, in which case the first day of the month would be day 0, and the first year of a century would be 0 + the century. But it is not consistent and, by convention, months and days are already numbers starting with 1. Why confuse things just because you are a programmer who likes to put the months in an array starting with a zero offset? In that case, that offset should be calculated and used internally, not by forcing everyone else to add 1 to the month everywhere it is used. I agree with the poster that some common standards were made by people exhibiting ID-10-T errors.
-
Not that I use it, but I thought arrays in VB were 1-based, and people hate it for that. Well, that and many other reasons. Are you advocating we should follow the VB model? :-) month[0] being January makes sense to me. That said, an enum defining month names starting at 1 also make sense to me. I see no way of ever reconciliating these sort of idiosyncrasies, unfortunately.
Wasn't Javascript born out of C/C++? Then, that is why lists and arrays begin at 0 and not 1.
-
Wasn't Javascript born out of C/C++? Then, that is why lists and arrays begin at 0 and not 1.
-
I hear you, but ultimately, a month number is not an array index. The dumb thing is using them as such...'cuz then, somebody at some point has no choice but to add or subtract 1 because we're dealing with different "currencies". X|
I agree. That is why I also agree with the original poster that a JavaScript month should not be starting with zero. I was just trying to say that, if one is being aggravatingly dumb, at least be consistent about it. I wonder just who it was who made the decision to make months start with zero, and what he is doing now. Is he sitting in an easy chair with his tea and crumpets, musing about his wonderful history, or is he hiding in a safehouse in fear from those of us who didn't like his work. :-)
-
I agree. That is why I also agree with the original poster that a JavaScript month should not be starting with zero. I was just trying to say that, if one is being aggravatingly dumb, at least be consistent about it. I wonder just who it was who made the decision to make months start with zero, and what he is doing now. Is he sitting in an easy chair with his tea and crumpets, musing about his wonderful history, or is he hiding in a safehouse in fear from those of us who didn't like his work. :-)