line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
|
2
|
|
|
|
|
|
|
use 5.010001; |
3
|
1
|
|
|
1
|
|
1988
|
use strict; |
|
1
|
|
|
|
|
3
|
|
4
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
22
|
|
5
|
1
|
|
|
1
|
|
4
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
189
|
|
6
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:PERLANCAR'; # AUTHORITY |
7
|
|
|
|
|
|
|
our $DATE = '2022-10-12'; # DATE |
8
|
|
|
|
|
|
|
our $DIST = 'Sah-Schemas-Date'; # DIST |
9
|
|
|
|
|
|
|
our $VERSION = '0.018'; # VERSION |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
+{ |
12
|
|
|
|
|
|
|
v => 4, |
13
|
|
|
|
|
|
|
summary => 'Convert English day-of-week name (e.g. su, MON, Tuesday) to number (1-7, 1=Monday)', |
14
|
1
|
|
|
1
|
0
|
12
|
prio => 50, |
15
|
|
|
|
|
|
|
}; |
16
|
|
|
|
|
|
|
} |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my %args = @_; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $dt = $args{data_term}; |
21
|
1
|
|
|
1
|
0
|
16
|
|
22
|
|
|
|
|
|
|
my $res = {}; |
23
|
1
|
|
|
|
|
2
|
my $pkg = __PACKAGE__; |
24
|
|
|
|
|
|
|
|
25
|
1
|
|
|
|
|
2
|
$res->{expr_match} = "!ref($dt)"; |
26
|
1
|
|
|
|
|
2
|
$res->{expr_coerce} = join( |
27
|
|
|
|
|
|
|
"", |
28
|
1
|
|
|
|
|
2
|
"do { ", |
29
|
1
|
|
|
|
|
6
|
|
30
|
|
|
|
|
|
|
# since this is a small translation table we put it inline, but for |
31
|
|
|
|
|
|
|
# larger translation table we should move it to a separate perl module |
32
|
|
|
|
|
|
|
"\$$pkg\::dow_nums ||= {", |
33
|
|
|
|
|
|
|
" mo=>1, mon=>1, monday=>1, ", |
34
|
|
|
|
|
|
|
" tu=>2, tue=>2, tuesday=>2, ", |
35
|
|
|
|
|
|
|
" we=>3, wed=>3, wednesday=>3, ", |
36
|
|
|
|
|
|
|
" th=>4, thu=>4, thursday=>4, ", |
37
|
|
|
|
|
|
|
" fr=>5, fri=>5, friday=>5, ", |
38
|
|
|
|
|
|
|
" sa=>6, sat=>6, saturday=>6, ", |
39
|
|
|
|
|
|
|
" su=>7, sun=>7, sunday=>7, ", |
40
|
|
|
|
|
|
|
"}; ", |
41
|
|
|
|
|
|
|
"\$$pkg\::dow_nums->{lc $dt} || $dt; ", |
42
|
|
|
|
|
|
|
"}", |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
$res; |
46
|
|
|
|
|
|
|
} |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
3
|
1; |
49
|
|
|
|
|
|
|
# ABSTRACT: Convert English day-of-week name (e.g. su, MON, Tuesday) to number (1-7, 1=Monday) |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=pod |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
=encoding UTF-8 |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
=head1 NAME |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Data::Sah::Coerce::perl::To_int::From_str::convert_en_dow_name_to_num - Convert English day-of-week name (e.g. su, MON, Tuesday) to number (1-7, 1=Monday) |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head1 VERSION |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
This document describes version 0.018 of Data::Sah::Coerce::perl::To_int::From_str::convert_en_dow_name_to_num (from Perl distribution Sah-Schemas-Date), released on 2022-10-12. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head1 SYNOPSIS |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
To use in a Sah schema: |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
["int",{"x.perl.coerce_rules"=>["From_str::convert_en_dow_name_to_num"]}] |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
=head1 DESCRIPTION |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
This rule can convert English day-of-week names like: |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
su |
75
|
|
|
|
|
|
|
MON |
76
|
|
|
|
|
|
|
Tuesday |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
to corresponding day-of-week numbers (i.e. 7, 1, 2 in the examples above). |
79
|
|
|
|
|
|
|
Unrecognized strings will just be passed as-is. |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
=for Pod::Coverage ^(meta|coerce)$ |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 HOMEPAGE |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Please visit the project's homepage at L<https://metacpan.org/release/Sah-Schemas-Date>. |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=head1 SOURCE |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
Source repository is at L<https://github.com/perlancar/perl-Sah-Schemas-Date>. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 AUTHOR |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
perlancar <perlancar@cpan.org> |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=head1 CONTRIBUTING |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
To contribute, you can send patches by email/via RT, or send pull requests on |
99
|
|
|
|
|
|
|
GitHub. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Most of the time, you don't need to build the distribution yourself. You can |
102
|
|
|
|
|
|
|
simply modify the code, then test via: |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
% prove -l |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
If you want to build the distribution (e.g. to try to install it locally on your |
107
|
|
|
|
|
|
|
system), you can install L<Dist::Zilla>, |
108
|
|
|
|
|
|
|
L<Dist::Zilla::PluginBundle::Author::PERLANCAR>, |
109
|
|
|
|
|
|
|
L<Pod::Weaver::PluginBundle::Author::PERLANCAR>, and sometimes one or two other |
110
|
|
|
|
|
|
|
Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond |
111
|
|
|
|
|
|
|
that are considered a bug and can be reported to me. |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
This software is copyright (c) 2022, 2020, 2019 by perlancar <perlancar@cpan.org>. |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
118
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head1 BUGS |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
Please report any bugs or feature requests on the bugtracker website L<https://rt.cpan.org/Public/Dist/Display.html?Name=Sah-Schemas-Date> |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
When submitting a bug or request, please include a test-file or a |
125
|
|
|
|
|
|
|
patch to an existing test-file that illustrates the bug or desired |
126
|
|
|
|
|
|
|
feature. |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=cut |