in reply to Between Two Times??? Help!

ACJavascript,
What you asked for help on, and what you said you are trying to solve are two different things.
  • Determine if something happened less than 24 hours ago
  • Determine if one time stamp is between two other time stamps

    For the first one, you could simply do this:

    #!/usr/bin/perl -w use strict; my $Cut_Off = time - ( 24 * 60 * 60); my $First_Sign_In = 1; #some function to get the timestamp - see modul +e suggestions later if ($First_Sign_In > $Cut_Off) { print "Welcome\n"; } else { print "Sorry, you need to contact me\n"; }
    You could have a look at Date::Manip or Time::Local for help in converting dates to timestamps.

    The second part of your node - did something happen between two dates, can be solved with the following pseudo code:

  • Convert low end boundary to time stamp
  • Convert high end boundary to time stamp
  • Convert event to time stamp
  • If event greater than low and less than high, move on

    I hope this helps - cheers L~R.

  • Replies are listed 'Best First'.
    Re: Re: Between Two Times??? Help!
    by ACJavascript (Acolyte) on Mar 22, 2003 at 16:45 UTC
      Very interesint,,,,

      Is there any way of doing this without using modules?
        ACJavascript,
        It is trivial to do the less than 24 hours thing. Just store the value in timestamp format when the person logs in and retrieve it later ($first_logon = time;). That way you can retrieve it when you are determining the cut off. As far as converting a date into a timestamp - yes it is possible without modules or the module itself wouldn't be possible. Date::Manip is very fast because it uses a C backend. Time::Local basically just uses convergence by guessing at the time and then lowering/highering values until it locks in on its target. It also uses a cache to make repeated checks of the same month faster, so I wouldn't suggest re-inventing these wheels.

        Cheers - L~R