File Coverage

blib/lib/Readonly/Values/Days.pm
Criterion Covered Total %
statement 18 18 100.0
branch 2 2 100.0
condition n/a
subroutine 6 6 100.0
pod n/a
total 26 26 100.0


line stmt bran cond sub pod time code
1             package Readonly::Values::Days;
2              
3 1     1   354425 use strict;
  1         3  
  1         45  
4 1     1   5 use warnings;
  1         2  
  1         89  
5              
6 1     1   858 use Readonly::Enum;
  1         6935  
  1         44  
7 1     1   724 use Readonly;
  1         5922  
  1         82  
8 1     1   9 use Exporter qw(import);
  1         3  
  1         685  
9              
10             =head1 NAME
11              
12             Readonly::Values::Days - Days Constants
13              
14             =head1 VERSION
15              
16             Version 0.01
17              
18             =cut
19              
20             our $VERSION = '0.01';
21              
22             =head1 SYNOPSIS
23              
24             use Readonly::Values::Days;
25              
26             # Iterate full day names
27             for my $name (@day_names) {
28             printf "%-9s => %2d\n", ucfirst($name), $days{$name};
29             }
30              
31             =cut
32              
33             Readonly::Enum our ($MON, $TUE, $WED, $THU, $FRI, $SAT, $SUN) => 1;
34              
35             Readonly::Hash our %days => (
36             # Full names
37             'monday' => $MON,
38             'tuesday' => $TUE,
39             'wednesday' => $WED,
40             'thursday' => $THU,
41             'friday' => $FRI,
42             'saturday' => $SAT,
43             'sunday' => $SUN,
44              
45             # Abbreviations
46             'mon' => $MON,
47             'tue' => $TUE,
48             'wed' => $WED,
49             'thu' => $THU,
50             'fri' => $FRI,
51             'sat' => $SAT,
52             'sun' => $SUN
53             );
54              
55             Readonly::Array our @day_names => (
56             'monday',
57             'tuesday',
58             'wednesday',
59             'thursday',
60             'friday',
61             'saturday',
62             'sunday'
63             );
64              
65             Readonly::Array our @short_day_names => map { _shorten($_) } @day_names;
66              
67             Readonly::Hash our %day_names_to_short => map { $_ => _shorten($_) } @day_names;
68              
69             our @EXPORT = qw(
70             $MON $TUE $WED $THU $FRI $SAT $SUN
71             %days
72             @day_names
73             @short_day_names
74             %day_names_to_short
75             );
76              
77             # Helper routine: Shorten strings to their first three characters
78             sub _shorten {
79 20     20   385146 my $str = $_[0];
80              
81 20 100       129 return unless defined $str;
82 19         314 return substr($str, 0, 3);
83             }
84              
85             =head1 AUTHOR
86              
87             Nigel Horne, C<< >>
88              
89             =head1 BUGS
90              
91             =head1 SEE ALSO
92              
93             =head1 SUPPORT
94              
95             This module is provided as-is without any warranty.
96              
97             Please report any bugs or feature requests to C,
98             or through the web interface at
99             L.
100             I will be notified, and then you'll
101             automatically be notified of progress on your bug as I make changes.
102              
103             You can find documentation for this module with the perldoc command.
104              
105             perldoc Readonly::Values::Days
106              
107             You can also look for information at:
108              
109             =over 4
110              
111             =item * MetaCPAN
112              
113             L
114              
115             =item * RT: CPAN's request tracker
116              
117             L
118              
119             =item * CPAN Testers' Matrix
120              
121             L
122              
123             =item * CPAN Testers Dependencies
124              
125             L
126              
127             =back
128              
129             =head1 LICENSE AND COPYRIGHT
130              
131             Copyright 2025 Nigel Horne.
132              
133             Usage is subject to licence terms.
134              
135             The licence terms of this software are as follows:
136              
137             =over 4
138              
139             =item * Personal single user, single computer use: GPL2
140              
141             =item * All other users (including Commercial, Charity, Educational, Government)
142             must apply in writing for a licence for use from Nigel Horne at the
143             above e-mail.
144              
145             =back
146              
147             =cut
148              
149             1;