Closed ghost closed 8 years ago
I don't think 0 is a valid year, actually, so you might want to make that > 0 instead? I could be wrong though. (Also, does this representation not support BCE dates? Not that there'd be much use for them even if it did...)
Giving 0 as the year results in a valid date in javascript (negative numbers do not),
d = new Date(0, 0, 1)
Mon Jan 01 1900 00:00:00 GMT-0600 (CST)
It's a little weird because it does require some knowledge about how Javascript works, but I figure as long as we are restricting input to valid numbers, a user will be able to figure out how to use the blocks for their intended purposes. For example to actually get year 0 in javascript you have to set the year explicitly
d.setFullYear(0)
-62167197600000
d
Sat Jan 01 0 00:00:00 GMT-0600 (CST)
So if thats something we want to support we could add blocks for setting year/month/day individually in a future PR.
Ehh... using a two-digit year isn't really a great idea, honestly. Especially since it becomes weird after 1999 – I'd guess you pass 100 in order to get the year 2000? I think it would be better to require the 4-digit year. Which means year 0 shouldn't be valid, since the CE era begins at year 1.
We should restrict years to four digits (or at least enforce year=17
equals BCE 17 not 1917, but we should do that at the block and integration level.
:shipit:
Uh, year=17
should be 17 CE, not 17 BCE. :P
Err, right. What I meant, not what I said.
I will write up an issue for that, and mark it "good first bug" for the next round of UCOSP students (unless someone else has a chance to get to it before then!)
Add tests for date blocks.
Also change
getMonth()
block to return month numbers in range 1-12 (instead of 0-11) and restrict year value to be >= 0 when creating a new date.