Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Advanced date formatting - help

Community Beginner ,
Jul 15, 2008 Jul 15, 2008
Hi All,

Has anyone seen a tag, or got an algorithm that will format date ranges?

I want to go from

12, 13, 20, 21 September, 6, 7, 8, 9, 10, 11, 12 October

to

12-13, 20-21 September, 6-12 October


David Heacock
277
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Beginner , Jul 16, 2008 Jul 16, 2008
Very cool :-)

Not quite what I was looking for, but still very cool. I ended up just building a set of nested loops and arrays to do this. Not very elegant, but effective.
Translate
LEGEND ,
Jul 15, 2008 Jul 15, 2008
you are formatting strings, not date ranges.
and, no, i do not know of a tag or an algorithm to do it, but someone
else may come up with a crafty regex... i would give it a go myself if
it wasn't so darn late...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 15, 2008 Jul 15, 2008
Laverda668 wrote:
> Has anyone seen a tag, or got an algorithm that will format date ranges?

the latest icu4j has this (maybe overkill for your purposes):

http://www.sustainablegis.com/blog/cfg11n/index.cfm?mode=entry&entry=102C955B-20ED-7DEE-2AA628417A03...

i haven't had a chance to wrap any of this up in a cfc but this more or less
does what you want:

<cfscript>
// create a date interval now-->4 weeks from now
// DateInterval class wants epoch offsets as LONG hence the getTime() calls
dI=createObject("java","com.ibm.icu.util.DateInterval").init(now().getTime(),dateAdd("ww",4,now()).getTime());
// create an interval format 3 letter months, 4 digit years, non-padded dates
diF=createObject("java","com.ibm.icu.text.DateIntervalFormat").getInstance("yMMMd");
writeoutput("#dif.format(di)#");
</cfscript>

which produces:

Jul 16 – Aug 13, 2008

currently this only works for gregorian calendar.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Jul 16, 2008 Jul 16, 2008
LATEST
Very cool :-)

Not quite what I was looking for, but still very cool. I ended up just building a set of nested loops and arrays to do this. Not very elegant, but effective.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources