views:

42

answers:

1

Say you have the following date range:

2010-04-10 - 2010-04-15

As a human, I might write this as April 10 - 15, 2010, or something like that. Not sure if there is a defined correct way of writing ranges like that, but anyways, if you were to do something like that, how would you do that? I'm not even sure where to begin...

I'd like to do this so that the date ranges potentially can be more compact, easier to read and also nicer looking.

+5  A: 

I don't think there's a defined way to do, basically it's just logic. Try writing down in plain text what you think the rules should be with some examples. Like the example you gave is a good one. What if they're different months? What if it was April 2005 to April 2007, is that April 2005-2007?

Once you've got your plain text rules, the code will be easy. It's just about deciding on how you want to format it.

UltimateBrent
Absolutely right. This is not a coding problem. It's a specification problem.
wallyk