Hi. Would it be possible to have current date as seconds (since 1970-01-01 00:00:00 UTC) to use in columns? I'd like to format last_played as "X days/months/years ago" instead of playing date. I know I can get current date with %x but I couldn't figure out a way to use that to calculate time difference from last_played and get it to seconds, which is needed for formattime().

I can easily add a function that returns the number of seconds since 1970, so I guess I can add it. Though I should add a better way to do that.
Also there is an option (in Misc. tab) that allows you to configure the default time format used based in the number of seconds from now. Though I'm not very happy with it, as it changes the display everywhere (not just in columns) and it doesn't work quite right with "Today" as I explain in this bug : https://github.com/squentin/gmusicbrowser/issues#issue/13

#2 March 14, 2011, 17:15:19 Last Edit: March 14, 2011, 19:20:37 by laite
Quote from: Quentin Sculo on March 14, 2011, 16:43:11
I can easily add a function that returns the number of seconds since 1970, so I guess I can add it. Though I should add a better way to do that.
Also there is an option (in Misc. tab) that allows you to configure the default time format used based in the number of seconds from now. Though I'm not very happy with it, as it changes the display everywhere (not just in columns) and it doesn't work quite right with "Today" as I explain in this bug : https://github.com/squentin/gmusicbrowser/issues#issue/13

Oh, somehow I have missed that option in 'misc'.

One option could be providing $today (or $now?) - field and functions for getting day/month/year/seconds out of it, so it could be used like: "full_seconds($today)-full_seconds($lastplay)" or perhaps "'Today's month is'.month($today)".

Another idea for solution: hard-coded function daysago($lastplayed), which would return number of days as an integer. It would be possible to handle the "today/yesterday"-issue for example like this (I'm sorry, I can't code in perl) :

function daysago(lastplay)
{
  seconds_since_midnight = current_hour(24h mode)*3600+current_minute*60+current_second;
  # for example @ 9:30:06 seconds_since_midnight would be 9*3600+30*60+6=34206

  difference = (current_seconds_since_epoch_ - lastplay_) - seconds_since_midnight

  if (difference < 0) return 0;
  #played today

  else return (1 + floor(difference/(24*60*60)));
  #return the number of 'midnights' (rounded down)

}


Hope you get the idea.