Akopia Akopia Services

[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date ][Minivend by thread ]

Re: [mv] date/time calculation tag?



******    message to minivend-users from Hans-Joachim Leidinger <jojo@buchonline.net>     ******

Bill Randle schrieb:
> } ---------snipp--------
> } #!/usr/bin/perl
> } use Time::localtime;
> } use Time::Local;
> } my $expiredate = localtime(timelocal(00, 00, 00 , 10, 05, 2000));
> } $expiredate = $expiredate->yday;
> } print "expiredate : " . $expiredate . "\n";
> } my $current_time = localtime;
> } $current_time = $current_time->yday;
> } print "current_time : " . $current_time . "\n";
> }
> } my $lifetime = $expiredate - $current_time;
> } print "lifetime : " . $lifetime . "\n";
> }
> } print "This product expires in " . $lifetime . " !\n";
> } ---------snipp--------
> 
> The above script doesn't work for me, and I think, will have problems
> at the end of the year when 'yday' wraps around.

Aaah! Yes! This is right!

Strange! Hmmm...I noticed another misbehavior! The output was

server:/home/mvend[mvend]# date
Fr  28 Apr 2000 17:04:36 CEST
server:/home/mvend[mvend]# bin/testz.pl
expiredate : 161
current_time : 118
lifetime : 43
This product expires in 43 !
server:/home/mvend[mvend]# 


If I calculate right with my head, from today still Mai 10 2000 is 12
days. 

118 is right. But 161 is wrong! It should be as 130! Or not?

> What you use depends on how you have the date information stored
> away and what you are actually putting in your products file.
> Typically, the begin date is stored in YYYYmmddHHMM format,
> which makes it difficult to do these kinds of comparisons unless
> you convert it back into time() format (seconds since 1/1/1970).
> 
> There's a usertag included in mv4 that converts the current time
> to a formatted time, so I created my own usertag that does the
> inverse - i.e. calculates seconds given a formatted time. (There
> may be something in MV that does this already, but I haven't
> run across it.)

Thanks for the fine usefull UserTag! It is a fine example how to use a
UserTag with MVASP.

Joachim

-- 
-------------Hans-Joachim Leidinger---------------------

-
To unsubscribe from the list, DO NOT REPLY to this message.  Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list


Search for: Match: Format: Sort by: