getmusicbee.com

General => MusicBee Wishlist => Topic started by: Steven on July 18, 2012, 10:38:55 PM

Title: Date formatting
Post by: Steven on July 18, 2012, 10:38:55 PM
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
Title: Re: Date formatting
Post by: paq on July 19, 2012, 02:02:08 AM
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?

Title: Re: Date formatting
Post by: Steven on July 19, 2012, 06:16:05 AM
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
Title: Re: Date formatting
Post by: Zak on July 19, 2012, 12:51:46 PM
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
Title: Re: Date formatting
Post by: Roadrunner on July 19, 2012, 04:20:34 PM
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.
Title: Re: Date formatting
Post by: Steven on July 19, 2012, 06:20:48 PM
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
Title: Re: Date formatting
Post by: Steven on July 19, 2012, 09:27:31 PM
this has the date function - you can use "n" to format the minutes
http://musicbee.niblseed.com/V2/MusicBee_Exe_Patched.zip
Title: Re: Date formatting
Post by: paq on July 19, 2012, 11:04:23 PM
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!

Title: Re: Date formatting
Post by: The Incredible Boom Boom on November 22, 2021, 09:36:45 PM
@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.?
Title: Re: Date formatting
Post by: Steven on November 23, 2021, 02:35:51 AM
this link has all the valid values
https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings
Title: Re: Date formatting
Post by: Orin on August 07, 2022, 11:24:13 AM
this link has all the valid values
https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-date-and-time-format-strings

This was extremely helpful! I spent a long time formatting am/pm but it turns out I could just use 'tt'; so much simpler 😁

If anyone else is looking for the full list of date/time formatting, this is an excellent reference.