1 package FS::rate_time_interval;
4 use base qw( FS::Record );
5 use FS::Record qw( qsearch qsearchs );
9 FS::rate_time_interval - Object methods for rate_time_interval records
13 use FS::rate_time_interval;
15 $record = new FS::rate_time_interval \%hash;
16 $record = new FS::rate_time_interval { 'column' => 'value' };
18 $error = $record->insert;
20 $error = $new_record->replace($old_record);
22 $error = $record->delete;
24 $error = $record->check;
28 An FS::rate_time_interval object represents an interval of clock time during
29 the week, such as "Monday, 7 AM to 8 PM". FS::rate_time_interval inherits
30 from FS::Record. The following fields are currently supported:
40 Start of the interval, in seconds from midnight on Sunday.
48 A foreign key to an L<FS::rate_time> object representing the set of intervals
49 to which this belongs.
60 Creates a new example. To add the example to the database, see L<"insert">.
62 Note that this stores the hash reference, not a distinct copy of the hash it
63 points to. You can ask the object for a copy with the I<hash> method.
67 # the new method can be inherited from FS::Record, if a table method is defined
69 sub table { 'rate_time_interval'; }
73 Adds this record to the database. If there is an error, returns the error,
74 otherwise returns false.
78 # the insert method can be inherited from FS::Record
82 Delete this record from the database.
86 # the delete method can be inherited from FS::Record
88 =item replace OLD_RECORD
90 Replaces the OLD_RECORD with this one in the database. If there is an error,
91 returns the error, otherwise returns false.
95 # the replace method can be inherited from FS::Record
99 Checks all fields to make sure this is a valid example. If there is
100 an error, returns the error, otherwise returns false. Called by the insert
109 $self->ut_numbern('intervalnum')
110 || $self->ut_number('stime')
111 || $self->ut_number('etime')
112 || $self->ut_number('ratetimenum')
114 return $error if $error;
121 Returns the L<FS::rate_time> comprising this interval.
127 FS::rate_time->by_key($self->ratetimenum);
132 Returns two strings containing stime and etime, formatted
133 "Day HH:MM:SS AM/PM". Example: "Mon 5:00 AM".
137 my @days = qw(Sun Mon Tue Wed Thu Fri Sat);
142 sprintf('%s %02d:%02d:%02d %s',
143 $days[int($_/86400) % 7],
147 (($_/3600) % 24 < 12) ? 'AM' : 'PM' )
148 } ( $self->stime, $self->etime );
157 L<FS::rate_time>, L<FS::Record>, schema.html from the base documentation.