Skip to main content

Notice

Please note that most of the software linked on this forum is likely to be safe to use. If you are unsure, feel free to ask in the relevant topics, or send a private message to an administrator or moderator. To help curb the problems of false positives, or in the event that you do find actual malware, you can contribute through the article linked here.
Topic: Displaying user friendly date tags (Read 3364 times) previous topic - next topic
0 Members and 1 Guest are viewing this topic.

Displaying user friendly date tags

Hey guys, is there any title formatting that I can use to display the date in a more user friendly manner. For example:

Last played: today | yesterday | n days ago | n weeks ago | n months ago.

instead of

Last played: 06-10-2012, etc..

I have no idea on how to compare the date string in the %last_played% and compare it with system date strings.

EDIT: Found the following thread http://www.hydrogenaudio.org/forums/index....showtopic=45282. Will test it out.

Displaying user friendly date tags

Reply #1
I have tried out the natural date script as posted in post #1, however it only works with columns playlist. Is there any way to get the global value from the Panel Splitter?

Displaying user friendly date tags

Reply #2
Try using foo_dynfil. It probably is the cleanest way of calculating date-dependent field values.

Displaying user friendly date tags

Reply #3
Try using foo_dynfil. It probably is the cleanest way of calculating date-dependent field values.


Thanks but I have no idea on how to use it. Care to point me to some direction here?

 

Displaying user friendly date tags

Reply #4
1. Install the component. Restart.
2. Go to Preferences > Media Library > Dynamic Fields.
3. Click on the green plus icon. Enter a fieldname. Example: "relative_last_played".
4. Enter any valid title formatting code into the text box. Note the help icon, which explains the additional date/time functionality.

Example code (taken from your linked thread):
Code: [Select]
/////////////////////////////////////////
// RELATIVE TIMESTAMPS
// formerly known as natural language timestamps
// by topdownjimmy - v0.5.c - May 6, 2007
// modified for foo_dynfil by ojdo - June 11, 2012
/////////////////////////////////////////

// calculate days since last play
$puts(dayssince,$date_diff(%last_played%))

// correct "dayssince" to consider early AM to be an extension of previous day
$puts(dayssince,$sub($get(dayssince),$if($and($greater(7,$substr(%now%,12,13)),$greater($substr(%last_played%,12,13),6)),1,0)))
$if($and($greater($substr(%now%,12,13),6),$greater(7,$substr(%last_played%,12,13))),$puts(dayssince,$add($get(dayssince),1)),)

// calculate day of week of last play
$puts(calcdayofweek,$day_of_week(%last_played%))

// correct day of week to consider early AM to be an extension of previous day
$puts(calcdayofweek,$sub($get(calcdayofweek),$ifgreater(7,$substr(%last_played%,12,13),1,0)))
$if($strcmp($get(calcdayofweek),0),$puts(calcdayofweek,7),)

// calculate period of day of last play (night, morning, etc.)
$puts(dayperiod,$select($add(1,$substr(%last_played%,12,13)),Night,Night,Night,Night,Night,Night,Night,Morning,Morning,Morning,Morning,Morning,Afternoon
,Afternoon,Afternoon,Afternoon,Afternoon,Evening,Evening,Evening,Evening,Night,Night,Night))

// calculate natural language timestamp
$if(%last_played%,$puts(rel_timestamp,$ifgreater($get(dayssince),0,$ifgreater($get(dayssince),1,$ifgreater($get(dayssince),6,$if($and($greater($get(dayssince),21),$not($strcmp($left(%now%,7),$left(%last_played%,7)))),$if($not($strcmp($left(%now%,4),$substr(%last_played%,1,4))),$select($substr(%last_played%,6,7),January,February,March,April,May,June,July,August,September,October,November,December)' '$ifgreater($get(dayssince),334,$substr(%last_played%,1,4),),$ifgreater(2,$sub($substr(%now%,6,7),$substr(%last_played%,6,7)),'Last Month',$select($substr(%last_played%,6,7),January,February,March,April,May,June,July,August,September,October,November,December))),$ifgreater($div($add($get(dayssince),4),7),1,$div($add($get(dayssince),4),7)' Weeks Ago',Last Week)),$select($get(calcdayofweek),Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday)' '$get(dayperiod)),$if($strcmp($get(dayperiod),Night),Last,Yesterday)' '$get(dayperiod)),$if($strcmp($get(dayperiod),Night),Tonight,This $get(dayperiod)))),$puts(rel_timestamp,Never))

// and display
$get(rel_timestamp)

5. Press apply. Addding/removing/renaming fields needs a restart.
6. Use the new field with %_relative_last_played% like a usual tag value.

Displaying user friendly date tags

Reply #5
Thanks for the effort ojdo.

There seemed to be one improvement that could be made though. So far what I noticed is the year will only displayed if it is 1 year before now. E.g. If the track is last played on July 2011, it will displayed simply as July ; if it is last played on May 2011, then the exact string (with year appended) is displayed. Perhaps an additional check on whether the year is the current year is needed. If it is the current year, then omit the %year%, else just display it. Too bad I'm unsure on where to put that.

Displaying user friendly date tags

Reply #6
Here's a screenshot of implementing it: