Click here to Skip to main content
15,895,142 members

The Weird and The Wonderful

   

The Weird and The Wonderful forum is a place to post Coding Horrors, Worst Practices, and the occasional flash of brilliance.

We all come across code that simply boggles the mind. Lazy kludges, embarrassing mistakes, horrid workarounds and developers just not quite getting it. And then somedays we come across - or write - the truly sublime.

Post your Best, your worst, and your most interesting. But please - no programming questions . This forum is purely for amusement and discussions on code snippets. All actual programming questions will be removed.

 
GeneralRe: MSDN example Pin
0x3c015-Apr-09 4:28
0x3c015-Apr-09 4:28 
GeneralRe: MSDN example Pin
leppie15-Apr-09 4:31
leppie15-Apr-09 4:31 
GeneralRe: MSDN example Pin
Luc 64801115-Apr-09 4:42
Luc 64801115-Apr-09 4:42 
GeneralRe: MSDN example Pin
leppie15-Apr-09 4:45
leppie15-Apr-09 4:45 
GeneralRe: MSDN example Pin
leppie15-Apr-09 4:43
leppie15-Apr-09 4:43 
GeneralRe: MSDN example Pin
0x3c015-Apr-09 4:49
0x3c015-Apr-09 4:49 
GeneralRe: MSDN example Pin
leppie15-Apr-09 5:00
leppie15-Apr-09 5:00 
GeneralRe: MSDN example Pin
supercat921-Apr-09 7:52
supercat921-Apr-09 7:52 
For that approach to work, wouldn't you have to add 306 days to both the birthdate and the present time before using the Year and DayOfYear properties? The notion that someone born on 2/28/2000 would have had to wait 366 days to be "one year old", while someone born on 3/1/2000 would only have to wait 365 days, is somewhat artificial but it is certainly well-established.

#2/28/2000#.DayOfYear == 59
#2/28/2001#.DayOfYear == 59
#3/1/2000#.DayOfYear == 61
#3/1/2001#.DayOfYear == 60
#2/28/2000#.AddDays(306).DayOfYear == 365
#2/28/2001#.AddDays(306).DayOfYear == 365
#3/1/2000#.AddDays(306).DayOfYear == 1
#3/1/2001#.AddDays(306).DayOfYear == 1

Of course, adding 306 days has an ugliness all its own. My own preference would probably be to simply format the thing as MMDDHHMMSS, do a string compare, and adjust the year appropriately, but another option would be to format as YYYYMMDDHHMMSS, convert to a long or double, subtract, and divide by 10,000,000,000.
JokeRe: MSDN example Pin
Ian Shlasko15-Apr-09 3:44
Ian Shlasko15-Apr-09 3:44 
GeneralRe: MSDN example Pin
Yusuf15-Apr-09 3:58
Yusuf15-Apr-09 3:58 
GeneralRe: MSDN example [modified] (oops, my bad!) Pin
Lutosław15-Apr-09 11:23
Lutosław15-Apr-09 11:23 
GeneralWhy use the 'instanceof' Java operator when you can rethrow an exception? Pin
Juan1R13-Apr-09 3:49
Juan1R13-Apr-09 3:49 
GeneralSince you all like his code so well. Pin
EyeYamFedUp3-Apr-09 5:53
EyeYamFedUp3-Apr-09 5:53 
GeneralRe: Since you all like his code so well. Pin
Yusuf3-Apr-09 6:28
Yusuf3-Apr-09 6:28 
JokeHouse, I need a lobotomy Pin
fabrice.leal3-Apr-09 6:52
fabrice.leal3-Apr-09 6:52 
GeneralGuess His Experience Level PinPopular
EyeYamFedUp1-Apr-09 8:00
EyeYamFedUp1-Apr-09 8:00 
GeneralRe: Guess His Experience Level Pin
fred_1-Apr-09 8:22
fred_1-Apr-09 8:22 
GeneralRe: Guess His Experience Level Pin
EyeYamFedUp1-Apr-09 8:43
EyeYamFedUp1-Apr-09 8:43 
GeneralRe: Guess His Experience Level Pin
Daniel 'Tak' M.1-Apr-09 9:45
Daniel 'Tak' M.1-Apr-09 9:45 
GeneralRe: Guess His Experience Level Pin
Yusuf1-Apr-09 14:49
Yusuf1-Apr-09 14:49 
GeneralRe: Guess His Experience Level Pin
Viral Upadhyay2-Apr-09 0:06
Viral Upadhyay2-Apr-09 0:06 
GeneralRe: Guess His Experience Level Pin
Thomas Weller2-Apr-09 0:57
Thomas Weller2-Apr-09 0:57 
JokeRe: Guess His Experience Level Pin
BadKarma2-Apr-09 22:14
BadKarma2-Apr-09 22:14 
JokeRe: Guess His Experience Level Pin
Thomas Weller3-Apr-09 2:49
Thomas Weller3-Apr-09 2:49 
GeneralRe: Guess His Experience Level Pin
akyriako782-Apr-09 1:51
akyriako782-Apr-09 1:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.