|
Dude
You got to be making that up!
"To alcohol! The cause of, and solution to, all of life's problems" - Homer Simpson
|
|
|
|
|
The AM/PM suffix only makes sense on a 12-hour system, not a 24-hour clock. If you use an 24-hours based day, you already know whether the time is in the morning or evening. Otherwise, the 8 O'Clock needs the AM/PM suffix to discriminate between 8:00 (8 AM) and 20:00 (8 PM).
It's a ridiculous format, and that mistake is as grave as the function is coded. It'd be best to use the date-format as specified in the users' settings, or to use a predefined format. Making up your own format requires owning a country.
Bastard Programmer from Hell
|
|
|
|
|
Eddy Vluggen wrote: The AM/PM suffix only makes sense on a 12-hour system
true
|
|
|
|
|
Or... Assuming the string has only military time with no date:
string strReturn = DateTime.Parse(DateTime.MinValue.ToString("MM/dd/yyyy ") + strTime).ToString("tt");
If it has date and time:
string strReturn = DateTime.Parse(strTime).ToString("tt");
Kevin Rucker, Application Programmer
QSS Group, Inc.
United States Coast Guard OSC
Kevin.D.Rucker@uscg.mil
"Programming is an art form that fights back." -- Chad Hower
|
|
|
|
|
your solution is different from original.
What if the parameter string is not a number or number any other than one in switch?
The original will return empty string while yours - eather throw or return PM instead.
|
|
|
|
|
I know what you mean mate... the solution I put was just to show that whole function can be redundant. If I have to code it I will make sure of all exception and validations on client and server...
Zen and the art of software maintenance : rm -rf *
Math is like love : a simple idea but it can get complicated.
|
|
|
|
|
You should focus on making it future-proof.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
This is a little game.
Someone in CodeProject wrote this:
I'll let you guess what this does and how it should be named:
static int f(int v)
{
unchecked
{
v--;
v |= v >> 1;
v |= v >> 2;
v |= v >> 4;
v |= v >> 8;
v |= v >> 16;
v++;
}
return v;
}
For the record when I posted this I promise did not realize that previous post was speaking about the exact same thing.
How extraordinary is this?
|
|
|
|
|
Pascal Ganaye wrote: guess what this does
Checks if Leslie Nielsen is dead or not?
Panic, Chaos, Destruction. My work here is done.
Drink. Get drunk. Fall over - P O'H
OK, I will win to day or my name isn't Ethel Crudacre! - DD Ethel Crudacre
I cannot live by bread alone. Bacon and ketchup are needed as well. - Trollslayer
Have a bit more patience with newbies. Of course some of them act dumb - they're often *students*, for heaven's sake - Terry Pratchett
|
|
|
|
|
Round up to the next highest power of 2, written by Jacek Gajek, in the message bellow.
yes, i'm not funny
|
|
|
|
|
You should probably have waited until it wasn't the previous thread anymore
|
|
|
|
|
I can't really believe it.
I found this code in a string library I had downloaded from code project a few days before.
I had not read the previous post.
What are the odds? This is spooky.
|
|
|
|
|
Long back i saw this code chunk which was causing alot of issue once a while, unfortunately that code did not had proper logs/comments/exception catching mechanisms involved. So we did had to spend atleast half a day to find it..
class MyClass
{
static int value = 10;
static int Value { get { return Value; } }
}
At first it was a bit difficult to find where stackoverflow exception was occuring and then i was wondering what made the original developer do this stupid way and released with out even testing.
My Blog -> https://adventurouszen.wordpress.com/
|
|
|
|
|
I don't know if this also applies to static properties but I had once a similar case in a normal instance property. The main issue for me was that Visual Studio (I think it was 2003) crashed when I tried to debug code where this class was used. Why? Because the debugger tried to show the Value in the Watch-window and couldn't handle the StackOverflowException.
|
|
|
|
|
I've done that myself before. One of the reasons I like to use m_value and Value.
When it comes to pay the rent no matter what [...] I just blew a tranny [...] you do what you gotta do.
|
|
|
|
|
true and every mistake teaches us a lesson and this is one of those which changed my naming convention style of fields.
My Blog -> https://adventurouszen.wordpress.com/
|
|
|
|
|
Even Resharper advises you to use _value.
|
|
|
|
|
Pretty normal mistake although its kind of weird how it made it into release unless this bit of code is only run when some very obscure corner case or feature is hit...
I'm sure there is some good reason ($$$) why the C# team haven't implemented it but I still wonder why the compiler doesn't throw a warning in such cases...
modified 6-Jan-12 16:10pm.
|
|
|
|
|
well thats where one good programmer needs to improve his coding practices. Other wise such normal mistakes keep happening. Yep its true that it went to a production code.
Lets not depend fully over compiler, even programmers have to be a bit more smart too
My Blog -> https://adventurouszen.wordpress.com/
|
|
|
|
|
This often happens if you type the method before declaring the variable.
return value; will get corrected by the ide to:
return Value; when the ; is typed.
That does not excuse the original developer for not checking it.
It is also looks far too compressed to me having the entire property on one line, although that is a matter of formatting standards, I guess.
|
|
|
|
|
This is true and extremely annoying. If I wanted a capital I'd have typed it as such, damn you!
I like one line properties if they are doing something simple (as most are); it means there is more screen space available to see actual code. I'm generally in favour of condensing things as much as reasonably practical for that reason, and particularly dislike the C# standard for braces which wastes a ridiculous number of lines.
|
|
|
|
|
I'll use one-line properties if they're automatic: public Type Value { set; get; } , but otherwise they are:
public Type Value
{
set
{
_Value = value;
}
get
{
return _Value;
}
}
private Type _Value;
Software Zen: delete this;
|
|
|
|
|
The only sound rule that applies to all processes, standards, and approaches is the following:
"The only rule, is that there are exceptions to all rules"
I was talking to my coworkers (all former contractors) about SVN and when to commit, some said "on save", others "end of day" and of course "when I am done". This is interesting to me, that not everything is worth committing, and sometimes things are critical, that every line counts. This is just one of those things, we developers are pragmatic. Our careers are in constant Limbo, between heaven and hell, and the fragility is an ever-present reality. I am sure you have your own examples.
modified 5-Jan-12 14:48pm.
|
|
|
|
|
Reminds me of this old chestnut...
"All Generalisations are wrong, including this one!"
------------------------------------
I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave
CCC Link[ ^]
Trolls[ ^]
|
|
|
|
|
I hate all generalisations!
Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water
|
|
|
|