- Feature Articles
- CodeSOD
- Error'd
- Forums
-
Other Articles
- Random Article
- Other Series
- Alex's Soapbox
- Announcements
- Best of…
- Best of Email
- Best of the Sidebar
- Bring Your Own Code
- Coded Smorgasbord
- Mandatory Fun Day
- Off Topic
- Representative Line
- News Roundup
- Editor's Soapbox
- Software on the Rocks
- Souvenir Potpourri
- Sponsor Post
- Tales from the Interview
- The Daily WTF: Live
- Virtudyne
Admin
"This works well for months like ANF and POC." - clearly all those extra months you need to insert into the project schedule to allow for debugging this POC...
Admin
Weird, I wonder what date format has a 3-character month in the front.
Admin
Microsoft SQL Server's default. Try this:
Admin
Admin
You just wait until 2038 and you'll be sorry you didn't add in support for ANF.
Admin
Admin
Admin
Maybe it's supposed to work with yesterday's uebermorgen code? ANF would be a great name for that 13th month...
Admin
Admin
JavaScript's substring method gives you the substring from the start index, up to but not including the end index.
Admin
Fixed?
def MonthOk = (MONTHLIST.indexOf(date.substring(1, 4).toUpperCase()) % 3 == 0)
Admin
I don't see any handling for Smarch.
Admin
EPOCH is a valid month, perfectly cromulent.
Admin
Admin
If you are bored ask him what happens when the month doesn't start at index 1 but ... lets say ... at -2. The solution he comes up with should be entertaining.
Admin
Groovy has language support for not having to do null checks... and so this moron wrote a null check.
Admin
Or maybe use a sanitation library.
Admin
I've used that same trick myself, but made a bit more exclusive:
Found := pos( '/' + Month + '/', '/Jan/Feb/Mar/Apr/..../' ) > 0;
Works just fine.
Admin
Feb/Mar has always been my favorite month.
Admin
FILE_NOT_FOUND!!!
Admin
Maybe XOR the boolean with a copy of itself, then do a bitwise comparison with 0 and assign that to a third variable. Then return the third variable. This would all be wrapped in a try-catch block which would return TRUE as a "failsafe"
Admin
The 13th month is called Undecimber.
Admin
Admin
is equivocal same as equivalent?
Admin
Admin
Admin
From the very beginning programmers have had trouble with dates. I think it's because of poor social skills.
Admin
Well, in fairness, the month method does have a McCabe complexity of under 5. Clearly that's more important that actual correct functionality.
CAPTCHA: Consequat. The consequat of the low McCabe complexity was that the error was obvious.
Admin
I love the month of Rap!
Admin
Groovy strings have the same indexing as Java Strings, so first index is 0 not 1 (and second parameter of substring is the exclusive end index, as already noted).
So the following are valid month names: HANF, SPOCK!
Admin
Admin
And Java still supports it.
Admin
Forgot how much I hate that.
Admin
Now try that in python34
Thankfuly this works:
Admin
Admin
I don't know anything about Groovy, but assuming it wouldn't be possible to use a class, doesn't the language have arrays? :s
Admin
I suppose some people would greatly prefer the month of "RAP".
Admin
The reason this makes sense is that the index locations are between the items. Once you grasp that, you don't have concerns about inclusive versus exclusive positions.
Icon does the same thing.
Admin
When you use this syntax it makes a bit more sense. I won't say I like it but it's not horrible.
Admin
Don't ever start thinking of positions "between" items, because such a thing just does not exist and you'll be even more likely to make off-by-one errors.
Admin
If they are between, then range(1,10) should print from 2 - 9 and not 1 -9.
Admin
This trick does in fact result in getting range(1,10) = 1,2,...,9.
Thinking of range indexes as sitting on the edges between elements, like marks on the x-axis, is a very reliable way of remembering how ranges work. It's saved me from substring trouble tons of times.
Admin
not only POC ... but even POCAHONTAS will work
Admin
Compilers are buggy. You can't trust them.