The eAuction Support Forums
https://www.everyscript.de/cgi-bin/yabb/YaBB.pl
eAuction 1.6.1.x >> Discussion of Functions >> sub get_the_time
https://www.everyscript.de/cgi-bin/yabb/YaBB.pl?num=1068990021

Message started by Forum Admin on 11/16/03 at 14:40:21

Title: sub get_the_time
Post by Forum Admin on 11/16/03 at 14:40:21

There is a time problem with some servers; therefore I changed the code of this function.
Replace your existing subroutine with this:

sub get_the_time {
   my @temp = @_;
   my $day_base;

   my $offset = 24 * 3600;  
   my $real_day = int(((localtime(time()))[3]));
   my $time_base = ((int((time() / 86400)))) * 86400;
   my $hour_base = int(((localtime($time_base))[2]));
   my $tdl = $config{'time_delay'} || 0;
   my @time = map { $_ = int($_); $_ } @temp;
   my ($d, $h, $m, $s) = @time;
       
   $time_base += (((24 - $hour_base)) * 3600);
   $day_base = int(((localtime($time_base))[3]));
       
         if ($real_day > $day_base) { $time_base += $offset }
         elsif ($real_day < $day_base) { $time_base -= $offset }
       
   $h > 23 && ($h = 23);
   $m > 59 && ($m = 59);
   $s > 59 && ($s = 59);
   
   $d *= 86400 || 0;
   $h *= 3600;
   $m *= 60;
   
   $tdl != 0 && ($tdl = int($tdl) *3600);
   
   $time_base + $d + $h + $m + $s - $tdl;
}

The current eAuction161.zip is allready containg this subroutine.

Title: Re: sub get_the_time
Post by Raymes on 01/28/04 at 03:29:57

Good day,

I'm using this subroutine in the 161 zip already, but it still gives alot of problems.. i think it could be because my time offset is at -16...

I've traced the error and found that at some times of the day, the date is correct and on others, it's one day after..

I've tried some quick plugs like adding a -1 to:
my $real_day = int(((localtime(time()))[3])-1);

But i guess i don't really understand the bugs here... Please help?

Title: Re: sub get_the_time
Post by Forum Admin on 01/28/04 at 12:35:51

Hello Rymes,

this should resolve your problems ...

#-#############################################
# Sub: Get Start-Time and Close-Time
# Written by: Dieter Werner
#-#############################################
sub get_the_time {
   my @temp = @_;
   my ($day_base, $ret_val);

   my $offset            = 24 * 3600;  
   my $real_day            = int(((localtime(time()))[3]));
   my $time_base      = ((int((time() / 86400)))) * 86400;
   my $hour_base      = int(((localtime($time_base))[2]));
   my $tdl                  = $config{'time_delay'} || 0;
   my @time            = map { $_ = int($_); $_ } @temp;
   my ($d, $h, $m, $s)      = @time;
       
   $tdl >= 0
               ?   ($time_base += (((24 - $hour_base)) * 3600))
               :   ($time_base -= (((24 + $hour_base)) * 3600));
   
   $day_base = int(((localtime($time_base))[3]));    

   $real_day > $day_base
               ?   ($time_base += $offset)
               :   ($time_base -= $offset);
       
   $h > 23 && ($h = 23);
   $m > 59 && ($m = 59);
   $s > 59 && ($s = 59);
   
   $d *= 86400 || 0;
   $h *= 3600;
   $m *= 60;
   
   $tdl != 0 && ($tdl = int($tdl) *3600);
     
   $time_base + $d + $h + $m + $s - $tdl;
}

Title: Re: sub get_the_time
Post by Raymes on 01/29/04 at 02:48:01

Thanks for your swift response, dieter, but somehow it still doesn't work.. The config is:
$config{'time_delay'}      = -16;

And the time when it fails to work is:
Current Time: 01.28.04 - 17:43:47  
Start-up: 01.29.04 - 17:43:34
or 5 minutes after last bid ...  
Deadline: 01.30.04 - 17:43:34
It was set to 0 offset for start-time

System time is around 01.29.04 - 09:43:47

Sorry for causing so much trouble to you, Dieter.. Thanks for your help!

Raymes


Title: Re: sub get_the_time
Post by Raymes on 01/29/04 at 11:18:39

After looking through the code again and again, i changed it as such.. For my site it seems to work.  Please kindly advise if this is the correct method to do this.

Raymes



#-#############################################
# Sub: Get Start-Time and Close-Time
# Contributed by: Dieter Werner
#-#############################################
sub get_the_time {
   my @temp = @_;
   my ($day_base, $ret_val);

   my $offset  = 24 * 3600;
   my $real_day  = int(((localtime(time()))[3]));
   my $time_base = time();
   my $hour_base = int(((localtime($time_base))[2]));
   my $tdl   = $config{'time_delay'} || 0;
   my @time  = map { $_ = int($_); $_ } @temp;
   my ($d, $h, $m, $s) = @time;


   $h > 23 && ($h = 23);
   $m > 59 && ($m = 59);
   $s > 59 && ($s = 59);

   $h -= (int(((localtime($time_base))[2]))+ $tdl + 24) if (int(((localtime($time_base))[2]))+ $tdl) < 0;
   $h -= (int(((localtime($time_base))[2]))+ $tdl) if (int(((localtime($time_base))[2]))+ $tdl) >= 0;
   $m -= int(((localtime($time_base))[1]));
   $s -= int(((localtime($time_base))[0]));

   $d *= 86400 || 0;
   $h *= 3600;
   $m *= 60;


    $time_base + $d + $h + $m + $s;
}

Title: Re: sub get_the_time
Post by Forum Admin on 02/03/04 at 12:42:31

I hope that this could be a more common solution of the problem.
Maybe someone can test the code under realtime-conditions.


Code:

#-#############################################
# Sub: Get Start-Time and Close-Time
# Written by: Dieter Werner
#-#############################################
sub get_the_time {
   my ($d, $h, $m, $s)      = @_;
   my $time_base      = ((int((time() / 86400)))) * 86400;
   my $hour_trash      = ((localtime($time_base))[2]) * 3600;
   my $tdl                  = int($config{'time_delay'}) || 0;
   my $offset            = 0;
   local $_;
   
   $h > 23      && ($h = 23);
   $m > 59      && ($m = 59);
   $s > 59      && ($s = 59);
   
   $d > 0 ? ($d *= 86400) : ($d = 0);    
   $h *= 3600;
   $m *= 60;
   
   $time_base -=  $hour_trash;
   
   abs($tdl) > 0 && do {
     $tdl *= 3600;
     
     $tdl > 0
         ?      do {
               ($h <= abs($tdl)) && ($offset = 24 * 3600);
               $time_base -= ($tdl - $offset);
           }
         :      do {
               ($h >= abs($tdl)) && ($offset = 24 * 3600);
               $time_base -= ($tdl + $offset);
           };
   };
   
   $time_base + $d + $h + $m + $s;
}


Title: Re: sub get_the_time
Post by jungle on 02/08/04 at 03:15:31

I have done some testing and this seems to work O.K. for me.  I have tested at the time I would normally find problems with some of the other code.  Will do some more testing and let you know if I find a problem.

Jim

Title: Re: sub get_the_time
Post by jungle on 02/09/04 at 18:43:02

Upon fruther testing I find that the time is out by 24 hours.  That is the posted time is minus one day.  

It seems strange as everything was working.  I will keep looking for the fault.  Have some ideas.

Jim

Title: Re: sub get_the_time
Post by Forum Admin on 02/09/04 at 20:34:47

Yes - you are right.
I saw the same by using another (Canadian too) installation of the script.

I'm helpless because everything is ok as long as I test it with my local network and with my external servers.

Title: Re: sub get_the_time
Post by Forum Admin on 02/10/04 at 15:02:15

Once again ...


#-#############################################
# Sub: Get Start-Time and Close-Time
# Written by: Dieter Werner
#-#############################################
sub get_the_time {
   my ($d, $h, $m, $s)      = @_;
   my $time_base      = ((int((time() / 86400)))) * 86400;    
   my $hour_trash      = ((localtime($time_base))[2]) * 3600;
   my $tdl                  = int($config{'time_delay'}) || 0;
   my $offset            = 0;
   
   my ($real_day, $base_day);
   local $_;    
   
   $time_base -=  $hour_trash;
   
   $real_day = (localtime)[7];
   $base_day = (localtime($time_base))[7];

   abs(($base_day - $real_day)) > 363
       ?   ($time_base += 86400)
       :   do {
               $base_day > $real_day && ($time_base -= 86400);
               $base_day < $real_day && ($time_base += 86400);
           };
   
   $h > 23      && ($h = 23);
   $m > 59      && ($m = 59);
   $s > 59      && ($s = 59);
   
   $d >= 1 ? ($d *= 86400) : ($d = 0);    
   $h *= 3600;
   $m *= 60;    
   
   abs($tdl) > 0 && do {
     $tdl *= 3600;
     
     $tdl > 0
         ?      do {
               ($h <= abs($tdl)) && ($offset = 86400);
               $time_base -= ($tdl - $offset);
           }
         :      do {
               ($h >= abs($tdl)) && ($offset = 86400);
               $time_base -= ($tdl + $offset);
           };
   };
   
   $time_base + $d + $h + $m + $s;
}

#-#############################################

Title: Re: sub get_the_time
Post by jungle on 02/11/04 at 15:04:34

I have tested this at different times of the day and night along with new and reposted items.  This script seems to work for me.  Tested for 24 hour period, will let you know if I find any problems.

Jim  :D

The eAuction Support Forums » Powered by YaBB 2.2!
YaBB © 2000-2007. All Rights Reserved.