Page 1 of 1

"Nth" Date Format for Airdate

Posted: 14 Sep 2018, 03:53
by Hashim
It doesn't seem like this forum is all that active lately, but it's worth a try anyway. Although actual documentation for all of the more advanced methods seems to be thin on the ground, I've managed to discover through a mixture of experimentation and forum searching most of what I want.

I've learnt that within the .format method, MMM can be specified for D, MMMM for Dec, MMMMM for December and so on (or something similar anyway). This has allowed me to get my airdate to display as (26 Dec 2003), which looks miles better than the default YYYY.MM.dd format and which I'm very happy with. However, what would make that airdate format absolutely perfect for me is the ability to specify the date in an "nth" format: 16th June 1995, 27th May 1997, 2nd December 2014, etc.

Does anyone know if this is already built into the program and I've just missed it? If not, is there any chance it could be implemented any time soon? It doesn't seem like it would take much work with similar functionality already built into the month, and I'd really appreciate it.

Thanks in advance!

Re: "Nth" Date Format for Airdate

Posted: 14 Sep 2018, 05:40
by rednoah
Adding 1st / 2nd / 3rd / 4th is possible but will require a bit of code. Not sure if there's a one-liner for that.

However, this date format might be close enough:

Code: Select all

16 June 1995

Code: Select all

dd MMMMM uuuu
Here's the technical documentation for data patterns that can be used in Java / Groovy / FileBot:
https://docs.oracle.com/javase/8/docs/a ... l#patterns


:idea: If you really really want 1st / 2nd / 3rd / 4th then I can help you write code for that, but I don't currently have time, so you'd have to wait a week or so.

Re: "Nth" Date Format for Airdate

Posted: 16 Sep 2018, 03:00
by Hashim
rednoah wrote:
14 Sep 2018, 05:40
Adding 1st / 2nd / 3rd / 4th is possible but will require a bit of code. Not sure if there's a one-liner for that.

However, this date format might be close enough:

Code: Select all

16 June 1995

Code: Select all

dd MMMMM uuuu
Here's the technical documentation for data patterns that can be used in Java / Groovy / FileBot:
https://docs.oracle.com/javase/8/docs/a ... l#patterns


:idea: If you really really want 1st / 2nd / 3rd / 4th then I can help you write code for that, but I don't currently have time, so you'd have to wait a week or so.
As I mentioned in my post, that's the format that I'm currently using. But if it involves writing custom scripting just for my specific use case, then it's too small a difference to make it worth that, I just assumed that this would be simple enough to add into the proper functionality of the program.

Re: "Nth" Date Format for Airdate

Posted: 16 Sep 2018, 17:03
by kim
I made this for you... maybe you can use this ?

Code: Select all

{def day = airdate.day; def suffix = day == 31 ? 'st' : day == 22 ? 'nd' : day == 23 ? 'rd' : 'th'; '('+airdate.format("dd'${suffix} 'MMM yyyy")+')'}
OR without ()

Code: Select all

{def day = airdate.day; def suffix = day == 31 ? 'st' : day == 22 ? 'nd' : day == 23 ? 'rd' : 'th'; airdate.format("dd'${suffix} 'MMM yyyy")}
output e.g.
15th Jun 2018

Re: "Nth" Date Format for Airdate

Posted: 16 Sep 2018, 17:23
by kim
version 2
I'm not sure what the correct way is but here you go:

Code: Select all

{def day = airdate.day; def suffix = (day == 31 || day == 21 || day == 1) ? 'st' : (day == 22 || day == 2) ? 'nd' : (day == 23 || day == 3) ? 'rd' : 'th'; airdate.format("dd'${suffix} 'MMM yyyy")}

Re: "Nth" Date Format for Airdate

Posted: 20 Sep 2018, 04:59
by rednoah
It's a bit of a handful, but that's how it works. If there's demand for this particular feature, then I can add a built-in helper function.