Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Date formatting

 [1/1] from: AJMartin::orcon::net::nz at: 31-Mar-2004 18:16


I've been writing lots of reports in HTML and I've updated my formatting functions for dates. You're welcome to use them. Pad: function [ "Pads a value with leading zeroes or trailing spaces or a specified fill character." Value [any-type!] "The value." Width [integer!] "The desired width." /With Fill [char!] "With the specified Fill character." ] [ Operator ] [ Operator: either any-string? Value [ any [Fill Fill: #" "] :tail ] [ Value: form Value any [Fill Fill: #"0"] :head ] head insert/dup Operator Value Fill Width - length? Value ] DD: func [Date [date!]] [ pad Date/day 2 ] MM: func [Date [date!]] [ pad Date/month 2 ] MMM: func [Date [date!]] [ copy/part pick Rebol/locale/Months Date/month 3 ] YYYY: func [Date [date!]] [ pad Date/year 4 ] DD-MM-YYYY: func [Date [date!]] [ rejoin [DD Date #"-" MM Date #"-" YYYY Date] ] YYYYMMDD: func [Date [date!]] [ rejoin [YYYY Date MM Date DD Date] ] DD: make object! [ MM: make object! [ YYYY: func [Date [date!]] [ rejoin [DD Date #"/" Rebol/words/MM Date #"/" Rebol/words/YYYY Date] ] ] MMM: make object! [ YYYY: func [Date [date!]] [ rejoin [DD Date #"/" Rebol/words/MMM Date #"/" Rebol/words/YYYY Date] ] ] ] D: make object! [ MM: make object! [ YYYY: func [Date [date!]] [ rejoin [Date/day #"/" Rebol/words/MM Date #"/" Rebol/words/YYYY Date] ] ] MMM: make object! [ YYYY: func [Date [date!]] [ rejoin [Date/day #"/" Rebol/words/MMM Date #"/" Rebol/words/YYYY Date] ] ] ] -- Andrew J Martin ICQ: 26227169 http://www.rebol.it/Valley/ http://valley.orcon.net.nz/ http://Valley.150m.com/