"Nth" Date Format for Airdate

All about user-defined episode / movie format expressions
Post Reply
Hashim
Posts: 2
Joined: 14 Sep 2018, 03:32

"Nth" Date Format for Airdate

Post by Hashim » 14 Sep 2018, 03:53

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!

User avatar
rednoah
The Source
Posts: 14114
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: "Nth" Date Format for Airdate

Post by rednoah » 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.
:idea: Please read the FAQ and How to Request Help.

Hashim
Posts: 2
Joined: 14 Sep 2018, 03:32

Re: "Nth" Date Format for Airdate

Post by Hashim » 16 Sep 2018, 03:00

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.

kim
Power User
Posts: 565
Joined: 15 May 2014, 16:17

Re: "Nth" Date Format for Airdate

Post by kim » 16 Sep 2018, 17:03

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

kim
Power User
Posts: 565
Joined: 15 May 2014, 16:17

Re: "Nth" Date Format for Airdate

Post by kim » 16 Sep 2018, 17:23

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")}

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest