| « Prev | Page 1 | Page 2 | Next » |
LISP of course supports it because it supports arbitrary compile-time computation. C++ also supports it, the expression template pattern is your friend, there are even libraries that implement it all for you -- say Boost Spirit. |
|
Are you sure that's a regex? It might just be thinly disguised exploit shellcode.
|
Re: Simple Date Validation
2012-04-20 01:10
•
by
Matt Westwood
|
The real WTF is that there are software professionals who don't understand a piece of such basic general knowledge about how the standard fucking calendar is constructed. One of the first exercises given to prospective candidates for a job in my company is to write a short program for counting the number of days between two dates reported in the Gregorian calendar. Checking for accurate handling of leap years is one of the crucial factors. If you're as clueless about the world around you as not to understand that, you're too clueless to work for me. |
Re: Simple Date Validation
2012-04-20 01:56
•
by
L.
(unregistered)
|
Erm... this is a regex to validate a date ... but good lmfao . who the hell hardcodes years and forgets about post 2100... if you're going to hardcode it, do it till the end. |
Re: Simple Date Validation
2012-04-20 02:05
•
by
L.
(unregistered)
|
Quick question though, why not use d at all ? |
Re: Simple Date Validation
2012-04-20 02:08
•
by
L.
(unregistered)
|
Shh Westwood, we all know you're unemployed anyway - and a sock puppet of Zunesis, and we all know what zunie does to socks... |
Re: Simple Date Validation
2012-04-20 03:34
•
by
Nappy
(unregistered)
|
The logic is in the way it is said. But if you have an international audience it's best to make it explicit i usually add (DD/MM/YYYY) and a picker so everybody knows for filename yyyymmdd makes the best sorting sense. And an other pain is the / . - used to separate the parts (and probably 16 other chars used) |
Re: Simple Date Validation
2012-04-20 04:12
•
by
codemonkey73
(unregistered)
|
Then the real WTF is java, this behaviour is completly brain dead so much so it is what javascript does as well. |
Given the bulk of that thing, the one thing it isn't is thinly disguised. Can shellcode be “thickly disguised”? (Overall, all this WTF shows is that jwz was right when the regexp user doesn't know what they're doing. Depressing…) |
I can't speak for you, but when i use an objet in java or other languages, i make sure to read an understand the documentation before claiming it won't work the way i want.
|
Re: Simple Date Validation
2012-04-20 05:23
•
by
Dave
(unregistered)
|
Sigh. You're new around here, aren't you? |
Re: Simple Date Validation
2012-04-20 05:25
•
by
Dave
(unregistered)
|
"The fourth of July, 1776"? |
Re: Simple Date Validation
2012-04-20 06:02
•
by
daef
(unregistered)
|
|
Submitter here :-)
The reason that 20's were rejected was the reason I fell over that piece of shiny regex. There were about 5 other Versions of the same regex all over the Project - different Versions had different bugs (couldn't even find one that passed a simple Test I wrote just for fun) It was simply replaced by a DateTime.TryParse btw. And WTF-Joe isn't a coworker anymore - so it didn't help him to stay. |
Re: Simple Date Validation
2012-04-20 08:22
•
by
bb
(unregistered)
|
|
If so; The Y3k bug is here!
|
Re: Simple Date Validation
2012-04-20 09:39
•
by
¯\(°_o)/¯ I DUNNO LOL
(unregistered)
|
Ah, so I see that Joe was an adherent to the WET principle, too! It would have also caused problems if you wanted to localize to US M0/DD/YYYY format or ISO YYYY-MM-DD format. |
Re: Simple Date Validation
2012-04-20 09:39
•
by
F
(unregistered)
|
However, as it only allows years in the range 2000-2099 in the first place, the fact that 1900 and 2100 aren't leap years is about as relevant as the fact that there was no year zero. |
Re: Simple Date Validation
2012-04-20 09:46
•
by
Shut up foo'
(unregistered)
|
It's "You're" and "insightful". Maybe you need a regex spell-checker. |
Re: Simple Date Validation
2012-04-20 10:24
•
by
Peter
(unregistered)
|
Does this mean that you think 1/1/2012 (say) should be rejected as invalid? |
Absolutely, and who could argue with code that looks like this:
Procedural code is so much better than Regexes |
Re: Simple Date Validation
2012-04-20 12:25
•
by
Re: Simple Date Validation
(unregistered)
|
|
Typical WTF idiocy responses (at least those that weren't trolls). Validating a date is a two step operation. First, parse the string into numbers for month, day, and year. Second, ensure that the month, day, and year are a valid date. Trying to cram a two part operation into a single line is a guaranteed source of WTFs, typically done by programmers who got A's on all of their homework problems but are complete disaster's when it comes to real work on production systems.
|
Re: Simple Date Validation
2012-04-20 13:02
•
by
asdf
(unregistered)
|
https://metacpan.org/module/Regexp::Grammars |
Re: Simple Date Validation
2012-04-20 13:58
•
by
Darkstar
(unregistered)
|
|
Using regular expressions to validate dates just isn't the right tool for the job. It is painstakinly complicated to make sure that all cases are covered.
A quick brute force check of this code revealed that the 10th of every month isn't accepted as a valid date. Did you see that? This is just an example of why regular expressions shouldn't be used - they are great for validating syntax, but suck at validating semantics. Also, my check above doesn't cover all the *invalid* dates that this regex may accept as valid. The only sane approach is to extract day, month and year, and then do checks on them. It is more readable and doesn't open up for crazy flukes like then one above. |
Re: Simple Date Validation
2012-04-20 13:59
•
by
Darkstar
(unregistered)
|
|
...and Perl 6, of course.
|
|
Regex is only used to show off knowhow. In real life program I am yet to find any good use for it.
|
Re: Simple Date Validation
2012-04-20 14:07
•
by
x
(unregistered)
|
Comprehension failure. |
Re: Simple Date Validation
2012-04-20 14:22
•
by
Franz Kafka
(unregistered)
|
I use it regularly (heh). But then, perl makes it easy. |
Re: Simple Date Validation
2012-04-20 14:29
•
by
Jay
(unregistered)
|
My bank's website says that dates should be entered in the from "mm/dd/yyyy". And they mean it: If you enter a single digit for the month or the day, they reject the date as invalid. |
Re: Simple Date Validation
2012-04-20 15:15
•
by
ObiWayneKenobi
|
Nagesh's manager? |
Re: Simple Date Validation
2012-04-20 16:07
•
by
international smoking pedant
(unregistered)
|
fixed some smoking shit |
|
Dear sirs and madams,
I regret to inform you of the untimely passing of Alex for the third time this week. As I will now be souly responsible for the content of this site, you can expect one article per week from this point forward. As I am lazy, however, I will not be changing the name. Sincerely yours, Remy Martin |
Re: Simple Date Validation
2012-04-20 16:23
•
by
It's a Cock! It's a Fist! It's Zunerman!
(unregistered)
|
What's with putting "sirs" first? Any true gentleman makes sure his lady comes first. Before gagging her with his cock |
Re: Simple Date Validation
2012-04-20 16:42
•
by
FatherStorm
(unregistered)
|
I see what you did there... (Captcha: quibus -- dative and ablative plural of qui) |
Re: Simple Date Validation
2012-04-20 18:46
•
by
Friedrice The great
(unregistered)
|
Then "Remy" would have to come first. |
|
After reading the comments, I've realized somthing. Some of you think way too hard about the solution and it's shittiness, without knowing the problem.
There are really only 3 problems with this WTF, in descdending order: 1.) It doesn't account for 10th and 20th dates (someone mentioned this earlier, I didn't confirm) 2.) It's a huge hard to maintain regex the dates thing comes first, because it means that #2 is true for no reason. You can't even say "at least it works". As far as it not detecting EVERY leap year, or not thinking < 1900 or > 2100 or dates, that doesn't matter. What if this code isn't to validate that ANY date is correct? It could be validating dates of jobs that this company has taken, which was founded in 2006. That means any job date before then is bad user input even if it's a valid date, and any date too far in the future is also _probably_ bad. In the above case, the programmer made an assumption that any date this code would ever process should never be from the next century. I see no problem with that... if this crap code is still being used 90 years from now to validate order dates, something more major is wrong. Of course, it means in 2012 I can still enter a job with a date of 2080, which is bogus. WITH THAT SAID, it's still a WTF. But some of your solutions would actually be less effective at solving the problem, if the case is what I described above. Just use a date library. |
Wrong. You now you have 04|08|12|16|20|24|28|32|36|40|44|48|52|56|60|64|68|72|76|80|84|88|92|96 problems. |
Re: Simple Date Validation
2012-04-23 04:17
•
by
L.
(unregistered)
|
Show me on the doll where the programmers who got A's touched you. |
Re: Simple Date Validation
2012-04-23 10:46
•
by
abdullah
(unregistered)
|
You missed the point, obvious troll is trying to incite the grammar nazis. |
Waiting to see how long it would take for someone who can count to read your comment? |
Re: Simple Date Validation
2012-04-23 15:11
•
by
Jay
(unregistered)
|
There are 3 kinds of people in the world: those who can count, and those who can't. |
Re: Simple Date Validation
2012-04-23 15:11
•
by
Jay
(unregistered)
|
He's very incitefull: he's always inciting trouble. |
Or the 10 types, the ones who understand binary and the ones who don't? |
Re: Simple Date Validation
2012-04-24 04:09
•
by
L.
(unregistered)
|
Or the 99 types, because stfu ? |
Re: Simple Date Validation
2012-04-26 03:43
•
by
daef
(unregistered)
|
i see what you did there :-) captcha: suscipere |
Re: Simple Date Validation
2012-05-04 11:46
•
by
Sorpigal
(unregistered)
|
|
I recommend that you read up on perl6 and specifically perl6 grammars and rules.
Example lifted from wikipedia:
|
Everybody stand back! I know regular expressions!
2012-07-08 14:43
•
by
cousteau
(unregistered)
|
|
That 20(00|04|08|12|16|20|24|28|32|36|40|44|48|52|56|60|64|68|72|76|80|84|88|92|96) must have something to do with leap years. Yeah, some basic algebraic operations would have been fine too, but that's cooler.
|
| « Prev | Page 1 | Page 2 | Next » |