home *** CD-ROM | disk | FTP | other *** search
-
- <HTML>
- <HEAD>
- <TITLE>Time::Period - A Perl module to deal with time periods.</TITLE>
- <LINK REL="stylesheet" HREF="../../../Active.css" TYPE="text/css">
- <LINK REV="made" HREF="mailto:">
- </HEAD>
-
- <BODY>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Time::Period - A Perl module to deal with time periods.</P></STRONG>
- </TD></TR>
- </TABLE>
-
- <A NAME="__index__"></A>
- <!-- INDEX BEGIN -->
-
- <UL>
-
- <LI><A HREF="#name">NAME</A></LI><LI><A HREF="#supportedplatforms">SUPPORTED PLATFORMS</A></LI>
-
- <LI><A HREF="#synopsis">SYNOPSIS</A></LI>
- <LI><A HREF="#description">DESCRIPTION</A></LI>
- <UL>
-
- <LI><A HREF="#period examples">PERIOD EXAMPLES</A></LI>
- </UL>
-
- <LI><A HREF="#version">VERSION</A></LI>
- <LI><A HREF="#history">HISTORY</A></LI>
- <LI><A HREF="#author">AUTHOR</A></LI>
- <LI><A HREF="#copyright">COPYRIGHT</A></LI>
- <LI><A HREF="#date">DATE</A></LI>
- <LI><A HREF="#source">SOURCE</A></LI>
- </UL>
- <!-- INDEX END -->
-
- <HR>
- <P>
- <H1><A NAME="name">NAME</A></H1>
- <P>Time::Period - A Perl module to deal with time periods.</P>
- <P>
- <HR>
- <H1><A NAME="supportedplatforms">SUPPORTED PLATFORMS</A></H1>
- <UL>
- <LI>Linux</LI>
- <LI>Solaris</LI>
- <LI>Windows</LI>
- </UL>
- <HR>
- <H1><A NAME="synopsis">SYNOPSIS</A></H1>
- <P><CODE>use Time::Period;</CODE></P>
- <P><CODE>$result = inPeriod($time, $period);</CODE></P>
- <P>
- <HR>
- <H1><A NAME="description">DESCRIPTION</A></H1>
- <P>The <STRONG>inPeriod</STRONG> function determines if a given time falls within a given
- period. <STRONG>inPeriod</STRONG> returns <STRONG>1</STRONG> if the time does fall within the given
- period, <STRONG>0</STRONG> if not, and <STRONG>-1</STRONG> if <STRONG>inPeriod</STRONG> detects a malformed time or
- period.</P>
- <P>The time is specified as per the <A HREF="../../../lib/Pod/perlfunc.html#item_time"><CODE>time()</CODE></A> function, which is assumed to
- be the number of non-leap seconds since January 1, 1970.</P>
- <P>The period is specified as a string which adheres to the format</P>
- <PRE>
- sub-period[, sub-period...]</PRE>
- <P>or the string ``none'' or whitespace. The string ``none'' is not case
- sensitive.</P>
- <P>If the period is blank, then any time period is assumed because the time
- period has not been restricted. In that case, <STRONG>inPeriod</STRONG> returns 1. If
- the period is ``none'', then no time period applies and <STRONG>inPeriod</STRONG> returns
- 0.</P>
- <P>A sub-period is of the form</P>
- <PRE>
- scale {range [range ...]} [scale {range [range ...]}]</PRE>
- <P>Scale must be one of nine different scales (or their equivalent codes):</P>
- <PRE>
- Scale | Scale | Valid Range Values
- | Code |
- *******|*******|************************************************
- year | yr | n where n is an integer 0<=n<=99 or n>=1970
- month | mo | 1-12 or jan, feb, mar, apr, may, jun, jul,
- | | aug, sep, oct, nov, dec
- week | wk | 1-6
- yday | yd | 1-365
- mday | md | 1-31
- wday | wd | 1-7 or su, mo, tu, we, th, fr, sa
- hour | hr | 0-23 or 12am 1am-11am 12noon 12pm 1pm-11pm
- minute | min | 0-59
- second | sec | 0-59</PRE>
- <P>The same scale type may be specified multiple times. Additional scales
- simply extend the range defined by previous scales of the same type.</P>
- <P>The range for a given scale must be a valid value in the form of</P>
- <PRE>
- v</PRE>
- <P>or</P>
- <PRE>
- v-v</PRE>
- <P>For the range specification v-v, if the second value is larger than
- the first value, the range wraps around unless the scale specification
- is year.</P>
- <P>Year does not wrap because the year is never really reset, it just
- increments. Ignoring that fact has lead to the dreaded year 2000
- nightmare. When the year rolls over from 99 to 00, it has really rolled
- over a century, not gone back a century. <STRONG>inPeriod</STRONG> supports the
- dangerous two digit year notation because it is so rampant. However,
- <STRONG>inPeriod</STRONG> converts the two digit notation to four digits by prepending
- the first two digits from the current year. In the case of 99-1972, the
- 99 is translated to whatever current century it is (probably 20th), and
- then range 99-1972 is treated as 1972-1999. If it were the 21st century,
- then the range would be 1972-2099.</P>
- <P>Anyway, if v-v is 9-2 and the scale is month, September, October,
- November, December, January, and February are the months that the range
- specifies. If v-v is 2-9, then the valid months are February, March,
- April, May, Jun, July, August, and September. 9-2 is the same as Sep-Feb.</P>
- <P>v isn't a point in time. In the context of the hour scale, 9 specifies
- the time period from 9:00:00 am to 9:59:59 am. This is what most people
- would call 9-10. In other words, v is discrete in its time scale.
- 9 changes to 10 when 9:59:59 changes to 10:00:00, but it is 9 from
- 9:00:00 to 9:59:59. Just before 9:00:00, v was 8.</P>
- <P>Note that whitespace can be anywhere and case is not important. Note
- also that scales must be specified either in long form (year, month,
- week, etc.) or in code form (yr, mo, wk, etc.). Scale forms may be
- mixed in a period statement.</P>
- <P>Furthermore, when using letters to specify ranges, only the first two
- for week days or the first three for months are significant. January
- is a valid specification for jan, and Sunday is a valid specification
- for su. Sun is also valid for su.</P>
- <P>
- <H2><A NAME="period examples">PERIOD EXAMPLES</A></H2>
- <P>To specify a time period from Monday through Friday, 9am to 5pm, use a
- period such as</P>
- <PRE>
- wd {Mon-Fri} hr {9am-4pm}</PRE>
- <P>When specifing a range by using -, it is best to think of - as meaning
- through. It is 9am through 4pm, which is just before 5pm.</P>
- <P>To specify a time period from Monday through Friday, 9am to 5pm on
- Monday, Wednesday, and Friday, and 9am to 3pm on Tuesday and Thursday,
- use a period such as</P>
- <PRE>
- wd {Mon Wed Fri} hr {9am-4pm}, wd{Tue Thu} hr {9am-2pm}</PRE>
- <P>To specify a time period that extends Mon-Fri 9am-5pm, but alternates
- weeks in a month, use a period such as</P>
- <PRE>
- wk {1 3 5} wd {Mon Wed Fri} hr {9am-4pm}</PRE>
- <P>Or how about a period that specifies winter?</P>
- <PRE>
- mo {Nov-Feb}</PRE>
- <P>This is equivalent to the previous example:</P>
- <PRE>
- mo {Jan-Feb Nov-Dec}</PRE>
- <P>As is</P>
- <PRE>
- mo {jan feb nov dec}</PRE>
- <P>And this is too:</P>
- <PRE>
- mo {Jan Feb}, mo {Nov Dec}</PRE>
- <P>Wait! So is this:</P>
- <PRE>
- mo {Jan Feb} mo {Nov Dec}</PRE>
- <P>To specify a period that describes every other half-hour, use something
- like</P>
- <PRE>
- minute { 0-29 }</PRE>
- <P>To specify the morning, use</P>
- <PRE>
- hour { 12am-11am }</PRE>
- <P>Remember, 11am is not 11:00:00am, but rather 11:00:00am - 11:59:59am.</P>
- <P>Hmmmm, 5 second blocks could be a fun period...</P>
- <PRE>
- sec {0-4 10-14 20-24 30-34 40-44 50-54}</PRE>
- <P>To specify every first half-hour on alternating week days, and the second
- half-hour the rest of the week, use the period</P>
- <PRE>
- wd {1 3 5 7} min {0-29}, wd {2 4 6} min {30-59}</PRE>
- <P>
- <HR>
- <H1><A NAME="version">VERSION</A></H1>
- <P>1.20</P>
- <P>
- <HR>
- <H1><A NAME="history">HISTORY</A></H1>
- <PRE>
- Version 1.20
- ------------
- - Added the ability to specify no time period.</PRE>
- <PRE>
- Version 1.13
- ------------
- - Cleaned up the error checking code.</PRE>
- <PRE>
- Version 1.12
- ------------
- - Updated email and web space information.</PRE>
- <PRE>
- Version 1.11
- ------------
- - Minor bug fix in 1.10.</PRE>
- <PRE>
- Version 1.10
- ------------
- - Released.</PRE>
- <P>
- <HR>
- <H1><A NAME="author">AUTHOR</A></H1>
- <P>Patrick Ryan <<A HREF="mailto:pgryan@geocities.com">pgryan@geocities.com</A>></P>
- <P>
- <HR>
- <H1><A NAME="copyright">COPYRIGHT</A></H1>
- <P>Copyright (c) 1997 Patrick Ryan. All rights reserved. This Perl module
- uses the conditions given by Perl. This module may only be distributed
- and or modified under the conditions given by Perl.</P>
- <P>
- <HR>
- <H1><A NAME="date">DATE</A></H1>
- <P>August 26, 1997</P>
- <P>
- <HR>
- <H1><A NAME="source">SOURCE</A></H1>
- <P>This distribution can be found at</P>
- <PRE>
- <A HREF="http://www.geocities.com/SiliconValley/Lakes/8456/">http://www.geocities.com/SiliconValley/Lakes/8456/</A></PRE>
- <P>or</P>
- <PRE>
- <A HREF="http://www.perl.com/CPAN/modules/by-module/Time/">http://www.perl.com/CPAN/modules/by-module/Time/</A></PRE>
- <TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=100%>
- <TR><TD CLASS=block VALIGN=MIDDLE WIDTH=100% BGCOLOR="#cccccc">
- <STRONG><P CLASS=block> Time::Period - A Perl module to deal with time periods.</P></STRONG>
- </TD></TR>
- </TABLE>
-
- </BODY>
-
- </HTML>
-