|
-
Mar 8th, 2016, 11:26 AM
#15
Re: Elegant code for TimeSince()
 Originally Posted by Ellis Dee
Note that in your first example, Start is after End. That's not supported.
That's fair enough, it's a very easy fix anyway (for others reading later: just swap the dates), I just thought I'd mention it in case you'd had successful tests.
 Originally Posted by Ellis Dee
I was unable to figure out how to account for the root problem. I successfully added an exception for months = 2 to 12, but the problem persisted with years and I couldn't readily solve that one. Which meant I ended up coding special logic for both months/days and years/months, so at this point I may as well do it straight up like in the OP since it's easier to maintain and includes weeks.
I haven't thought of a clever fix for the previous code (just the kind of thing you would have tried), so that's probably the way to go.
Keeping code short is nice, but correctness and maintainability are more important.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|