Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: setting limitations for users based on time

by sundialsvc4 (Abbot)
on Jan 02, 2015 at 16:15 UTC ( #1112013=note: print w/replies, xml ) Need Help??


in reply to setting limitations for users based on time

Yes, there must be someting more to it than just this.   All that you need to know is, what is the hour and minute of the current time-of-day.   The built-in module Time::Piece will very conveniently give you this.   There must be some starting and ending range of times that you care about.   If, for example, you must clock-in within 5 minutes either side of the hour ...

use Time::Piece; my $t = localtime; # RETURNS AN OBJECT unless ( ($t->minute <= 5) or ($t->minute >= 55) { die "You can't log in now!" }

There might be a little additional logic to “round up to the next hour” if minute >= 55 ...

Replies are listed 'Best First'.
Re^2: setting limitations for users based on time
by marto (Archbishop) on Jan 02, 2015 at 21:15 UTC

    Had you actually tested what you posted you'd know this doesn't compile.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1112013]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (8)
As of 2019-12-07 12:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Strict and warnings: which comes first?



    Results (161 votes). Check out past polls.

    Notices?