Gem... As time goes by..
-
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.
-
private string GetTime(string strShiftCode, string strTime)
{
string strReturn = "";switch (strTime) { case "01": strReturn = "AM"; break; case "02": strReturn = "AM"; break; case "03": strReturn = "AM"; break; case "04": strReturn = "AM"; break; case "05": strReturn = "AM"; break; case "06": strReturn = "AM"; break; case "07": strReturn = "AM"; break; case "08": strReturn = "AM"; break; case "09": strReturn = "AM"; break; case "10": strReturn = "AM"; break; case "11": strReturn = "AM"; break; case "12": strReturn = "PM"; break; case "13": strReturn = "PM"; break; case "14": strReturn = "PM"; break; case "15": strReturn = "PM"; break; case "16": strReturn = "PM"; break; case "17": strReturn = "PM"; break; case "18": strReturn = "PM"; break; case "19": strReturn = "PM
You should focus on making it future-proof.
I wanna be a eunuchs developer! Pass me a bread knife!
-
Yes, different notations for the same timepoint.
-
The Army (at least) took 2400 as the end of the day...and never acknowledged 0000 as existing. :p
So I rounded up my camel Just to ask him for a smoke He handed me a Lucky, I said "Hey, you missed the joke." My Mu[sic] My Films My Windows Programs, etc.
-
The Army (at least) took 2400 as the end of the day...and never acknowledged 0000 as existing. :p
So I rounded up my camel Just to ask him for a smoke He handed me a Lucky, I said "Hey, you missed the joke." My Mu[sic] My Films My Windows Programs, etc.
Then one second after that would be 240001 or 000001?
-
Then one second after that would be 240001 or 000001?
000001 But we just started the new logs at 0001Z. That minute inbetween was just ignored. Actually, come to think of it, we never used 2400Z, either. The day ended at 2359Z and the next started at 0001Z. :p
So I rounded up my camel Just to ask him for a smoke He handed me a Lucky, I said "Hey, you missed the joke." My Mu[sic] My Films My Windows Programs, etc.
-
ISO 8601 allows 24:00 as the end of the day, so it would be PM; AM starts at 00:00 (not that ISO 8601 recognizes AM/PM of course).
If you are dealing with instantaneity, 12:00:00 and 24:00:00 (or 0:00:00, if you prefer) are neither AM nor PM: the first is Noon and the second is Midnight.
Just think of it as evolution in action.
-
BobJanova wrote:
Anyone spot any more?
No need to set a string to return from the function. A simple return "AM"; or return "PM"; would suffice.
I'm not a programmer but I play one at the office
That's not really so much a horror as a stylistic choice, though one which I would also change as you have suggested there. Some people say that a single point of return is better because you don't have to look through the whole function to find escape points, and though I disagree with that (for one thing your function should be short enough it isn't a problem) I can see what they're getting at.
-
That's not really so much a horror as a stylistic choice, though one which I would also change as you have suggested there. Some people say that a single point of return is better because you don't have to look through the whole function to find escape points, and though I disagree with that (for one thing your function should be short enough it isn't a problem) I can see what they're getting at.
I disagree with the single point of return as well. To me it requires some degree of convoluting the code just to reach that point. I tried that approach for a while but I found myself having to add code rather than getting straight to the purpose of it. But then I've always tried to avoid having to take those few extra CPU cycles to get from point A to point B if point A++ gets the job done faster.
I'm not a programmer but I play one at the office
-
It's also wrong : "24" is "AM" :) Cheers
If you can read this, you don't have Papyrus installed