Author Topic: Date formatting  (Read 7285 times)

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 32353
i am sure this has come up before but cant find the post.
I have added a function to format date fields
eg.
sortable date:
<Date(<field>,"yyyymmdd">
or to get the year only:
<Date(<field>,"yyyy">
month formatted as 3 char text and year
<Date(<field>,"mmm-yyyy">

it will be in the next update after i have tested it some more

paq

  • Sr. Member
  • ****
  • Posts: 386
Cool, thanks! I for one wished for it :)

Two questions:

1. Will <Date(<Year>,"mm")> be null when a month is not defined in the tag <Year>? That is, can we use <IsNull(<Date(<Year>,"mm")>,true,false)> to see how defined a date is? :)

2. Are h, m and s also available for hours, minutes and seconds when these are defined?


Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 32353
month and day would be 1 for just a year
h and s are supported. For m, m by itself will be ok for minutes, but if you use mm; mmm; or mmmm they get mapped to MM; MMM; MMMM
reason being is because i think most people will try and use mm and end up getting minutes because they dont know about the capitalisation
i guess it could map "n" to "m" but i didnt think people would be interested to format the time over and about the windows default
Last Edit: July 19, 2012, 06:24:53 AM by Steven

Zak

  • Member
  • Hero Member
  • *****
  • Posts: 2024
Are h, m and s also available for hours, minutes and seconds when these are defined?
You record the time an album is released down to the seconds?! I thought I was nitpicky about tagging!  :D
Bee excellent to each other...

Roadrunner

  • Sr. Member
  • ****
  • Posts: 367
For m, m by itself will be ok for minutes, but if you use mm; mmm; or mmmm they get mapped to MM; MMM; MMMM
reason being is because i think most people will try and use mm and end up getting minutes because they dont know about the capitalisation
i guess it could map "n" to "m" but i didnt think people would be interested to format the time over and about the windows default
Shouldn't "m" be used for the month without leading zero, i.e. 1, 2, 3, ... 10, 11, 12 (in contrast to "mm": 01, 02, 03, ... 10, 11, 12)?

Maybe another approach could be, to say, if "m" or "mm" follows directly "h" (apart from constants like ".", ":") or will be followed directly by an "s" (not sure, if this 2nd case will be necessary"), then it stands for minutes. In all other cases for months. So, you just could define "d.mm.yyyy h:mm:ss", "yyyy-mm-dd hh.mm", "h.mm", "m:ss" or whatever.

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 32353
i forgot about a single m so will include that as well.
for the time component i dont want to spend time building complicated parsing to support hours and minutes unless someone can come up with a very good reason why they would want to format hours and minutes differently from the windows settings

Steven

  • Administrator
  • Hero Member
  • *****
  • Posts: 32353

paq

  • Sr. Member
  • ****
  • Posts: 386
Are h, m and s also available for hours, minutes and seconds when these are defined?
You record the time an album is released down to the seconds?! I thought I was nitpicky about tagging!  :D
Yeah, to be absolutely sure they appear in the right order ;) Just kidding, was asking out of curiosity since you can format tags like <Date added> where seconds are defined :) So no need to put in the extra effort in this function for me!


The Incredible Boom Boom

  • Hero Member
  • *****
  • Posts: 670
@Steven, although not a standard DateTime custom format string, is there an undocumented way to use the $Date() function to return the day of the week as a number? Mon == 1, Tue == 2, etc.?