Hi everyone,
this is my first post, thank you for taking the time to look into my problem.
Which is...
I use a custom column to store the publishing dates of magazines. These come in various formats like
So I use strings instead of dates or numbers.
These of course don't sort exactly but can easily be found as hierarchical items in the tag browser.
Now I want to extract a formatted date from this data:
1955.04.20
should be
1955-04-20
1955.04
should be
1955-04-00
1955
should be
1955-00-00
1955.Spring
should be
1955-00-00
1955.Spring/Summer
should be
1955-00-00
(the season data should be omitted completely).
What I have so far:
3 (hidden) columns to isolate year, month and day:
{#original_date:subitems(0,1)}
{#original_date:subitems(1,2)}
{#original_date:subitems(2,3)}
and a fourth to build the formatted date:
{#original_year:ifempty(0000)}-{#original_month:ifempty(00)}-{#original_day:ifempty(00)}
What I want to achieve:
So far I haven't wrapped my brain around the template program mode, I don't find a way to combine subitems() and ifempty().
Thanks in advance!
this is my first post, thank you for taking the time to look into my problem.
Which is...
I use a custom column to store the publishing dates of magazines. These come in various formats like
- 1955.04.20 (most exact)
- 1955.04
- 1955
- 1955.Spring
- 1955.Spring/Summer (worst case)
So I use strings instead of dates or numbers.
These of course don't sort exactly but can easily be found as hierarchical items in the tag browser.
Now I want to extract a formatted date from this data:
1955.04.20
should be
1955-04-20
1955.04
should be
1955-04-00
1955
should be
1955-00-00
1955.Spring
should be
1955-00-00
1955.Spring/Summer
should be
1955-00-00
(the season data should be omitted completely).
What I have so far:
3 (hidden) columns to isolate year, month and day:
{#original_date:subitems(0,1)}
{#original_date:subitems(1,2)}
{#original_date:subitems(2,3)}
and a fourth to build the formatted date:
{#original_year:ifempty(0000)}-{#original_month:ifempty(00)}-{#original_day:ifempty(00)}
What I want to achieve:
- get them all into one column
- check the month for non-integer data and replace it with "00"
So far I haven't wrapped my brain around the template program mode, I don't find a way to combine subitems() and ifempty().
Thanks in advance!