rejetto forum

Showing the Age value in a different way.

TSG · 21 · 15104

0 Members and 1 Guest are viewing this topic.

Offline TSG

  • Operator
  • Tireless poster
  • *****
    • Posts: 1935
    • View Profile
    • RAWR-Designs
Some people might want this, I am thinking of using it in a new template idea.

I would like to show the 'Age' of a file in a different format to the the current %item-modified% value. The suggested equation would be current date - modification date...

The format I am thinking of showing is somewhat common, basically we start off with 1m up to 59m then 1h.... then when it gets to 24h, it switches to 1d. This would be its simplest form.

A slight change to it would add weeks, so at 7 days, you get 1w. The next upgrade to this method would be to show a decimal value, so you end up with 1.1d, 1.1w.

Who is brave enough to work out an elegant method of doing this with macro ;)
« Last Edit: February 08, 2009, 03:54:45 PM by That_Stevens_Guy »



Offline TSG

  • Operator
  • Tireless poster
  • *****
    • Posts: 1935
    • View Profile
    • RAWR-Designs
lol no, this must be macro/server side only, that's why its a challenge ;)

It might require something new in HFS, or it might be possible with macro. I don't know.
« Last Edit: February 08, 2009, 03:04:40 PM by That_Stevens_Guy »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
mmm, i think it would be too hard without adding something new.
you need to get the timestamp before it gets converted to human form, when it is just a number. it is then easy to calculate the difference.

then, i need to expand {.time.} to let you specify the timestamp (at the moment it works only with the current time).

if you plan to work on it, i will implement these features.
« Last Edit: February 11, 2009, 03:26:52 PM by rejetto »


Offline TSG

  • Operator
  • Tireless poster
  • *****
    • Posts: 1935
    • View Profile
    • RAWR-Designs
This idea is for the same template I'm thinking of making the download only selected feature around. But it is an age display seen on many torrent and usenet search engines. So if implemented I can see other people using it also.


Offline Mars

  • Operator
  • Tireless poster
  • *****
    • Posts: 2059
    • View Profile
Quote
I'm thinking of making the download only selected feature around.

Do not get tired to look, the solution is already in my sources modified since the build 214, Quite as the possibility to rename, comment, delete,  restore, or destroy definitively and individually a file.

It will be soon available for all.

The template is already ready in several versions, only the management of the rights for the users is to be strengthened so as to leave no possible fault in case of error in a template
« Last Edit: February 08, 2009, 06:02:39 PM by mars »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
@tsg
i didn't understand from your reply if you want me to make them or not



Offline bacter

  • Operator
  • Tireless poster
  • *****
    • Posts: 681
    • View Profile
it would be nice to have two macros:

{.dtetim2nbr|21/08/2007 22:00:56.} returns numeric time from number of day (from 1-1-1900 for example) and time.

{.nbr2dtetim|numeric time.} returns a datetimestring.

I would love this functions because now y have to do some numeric macro acrobatics to create filenames based on inverse of time (higher datetime -> lower number) to have the files inverse ordered by filname. (Most recent files first)

i suppose that such functions are already part of delphi or exist in some lib.
your computer has no brain - use your own !


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile

Offline TSG

  • Operator
  • Tireless poster
  • *****
    • Posts: 1935
    • View Profile
    • RAWR-Designs
@bacter This feature would be nice, however those macros suggested are very ugly...

@rejetto Something nicer is needed, something universal even, and yes my reply was intended as a 'yes, do want'. You are correct rejetto, you can invert by age, however I do not understand the problem bacter is having.

@mars NICE, if you can get the 'download only selected items' in the latest public beta I would start to work on my new template :) keeping myself busy while looking for work.
« Last Edit: February 09, 2009, 08:48:18 AM by That_Stevens_Guy »


Offline bacter

  • Operator
  • Tireless poster
  • *****
    • Posts: 681
    • View Profile

@rejetto: i'am working on a template-module for small forums, where i already use the sort by date/time to show threads with most recent activities, but in the filename i maintain the creation-date of the thread and i wanted last created threads on top...  It happens, that when working on some project trying to solve one problem, i forget the KISS principle  ;D (this only happens to me, i'am sure  ! ;D). So instead of rearranging time simply to yymmddhhmm and sorting inverse, y used 31days months to get a number for mmdd etc..    all to avoid inverse sorting! (just thrown that stuff to the wastebasket!)

but as there remains the problem that @TSG pointed out (for me it is: las post  3 days ago, 25 minutos ago etc.) i proposed this two ugly macros, as i suppose that some timeconverting and calculation would be available in delphi.

As we can make with macros easy strings like  (yy)yymmddhhmm(ss) , perhaps it would be better and less ugly (this would serve to me and TSG i suppose) , if we could have a macro difftime.

{.difftime|0902101349|0901051050.}     that returns a string  like ddddhhmm

optional the macro could could admit only one parameter:

{.difftime|0902101349.}     that would return the difftime to system time.

your computer has no brain - use your own !


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
ok, next build should have everything you need.

+ new template symbols: %now% %item-added-dt% %item-modified-dt%
+ {.time.} supports new parameter "when" to use a different time than the current one
+ new template macro: trunc

the numeric format will be 1.0 for a day (then 1/24 for an hour).
to make non-integer computations you must use {.calc.}

then, you should make your macro to display the elapsed time.
my suggestion is to make something that will take 1 or 2 parameters.
if 2 parameters: subtract.

ok, i spent the last hour making it for you ... ::)

Code: [Select]
{.set|elapsed step|{:
    {.set|t| {.calc|({.^t.}-{.^r.})*$2.} .}
    {.set|r| {.substring||.|{.^t.}.} .}
    {.set|$1| {.^r.} .}
:}.}

{.set|elapsed|{:
    {.set|t| {.calc| {.if|$2| {.calc|$1-$2.} | $1/if.} /30 .} .}
    {.set|r| {.substring||.|{.^t.}.} .}
    {.set|months|{.^r.}.}
    {.^elapsed step|days|30.}   
    {.^elapsed step|hours|24.}   
    {.^elapsed step|minutes|60.}

    Time elapsed:
    {.cut||-1| {.comment|this will remove the last comma.}
    {.if|{.^months.}|{.^months.} month(s), .}
    {.if|{.^days.}|{.^days.} day(s), .}
    {.if|{.^hours.}|{.^hours.} hour(s), .}
    {.if|{.^minutes.}|{.^minutes.} minute(s),.}
    /cut.}
:}.}


usage example
{.^elapsed|%now%|%item-modified-dt%.}
« Last Edit: February 19, 2009, 02:06:22 AM by rejetto »


Offline TSG

  • Operator
  • Tireless poster
  • *****
    • Posts: 1935
    • View Profile
    • RAWR-Designs
Will give it a go!

What is the difference between %timestamp% and %now%? Don't worry I got it lol.

The macro seems to work nice though...

I hope you weren't working out this macro while driving :)
« Last Edit: February 12, 2009, 12:20:37 PM by That_Stevens_Guy »


Offline rejetto

  • Administrator
  • Tireless poster
  • *****
    • Posts: 13510
    • View Profile
i made some changes to the code above: it is not using {.trunc.} anymore.
i noticed {.substring.} is more than enough.
i think i should remove {.trunc.} support. opinions are welcome.