line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DateTime::Format::Sybase; |
2
|
|
|
|
|
|
|
|
3
|
2
|
|
|
2
|
|
27678
|
use strict; |
|
2
|
|
|
|
|
6
|
|
|
2
|
|
|
|
|
124
|
|
4
|
2
|
|
|
2
|
|
11
|
use warnings; |
|
2
|
|
|
|
|
4
|
|
|
2
|
|
|
|
|
56
|
|
5
|
2
|
|
|
2
|
|
2723
|
use DateTime::Format::Strptime; |
|
2
|
|
|
|
|
627743
|
|
|
2
|
|
|
|
|
457
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
=head1 NAME |
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
DateTime::Format::Sybase - Parse and format Sybase datetimes |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=cut |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
our $VERSION = '0.04'; |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 SYNOPSIS |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
use DateTime::Format::Sybase; |
18
|
|
|
|
|
|
|
use DBI; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
my $dbh = DBI->connect('dbi:Sybase:SERVER', 'sa', ''); |
21
|
|
|
|
|
|
|
$dbh->syb_date_fmt('ISO'); # output format |
22
|
|
|
|
|
|
|
$dbh->do('set dateformat mdy'); # input format |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my $dt = DateTime::Format::Sybase->parse_datetime( |
25
|
|
|
|
|
|
|
'2004-08-21 14:36:48.080' |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
DateTime::Format::Sybase->format_datetime($dt); # '08/21/2004 14:36:48.080' |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=head1 DESCRIPTION |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
Run the DBI calls as specified in L on connection to use this module |
33
|
|
|
|
|
|
|
with Sybase. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=cut |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
my $output_format = DateTime::Format::Strptime->new( |
38
|
|
|
|
|
|
|
pattern => '%Y-%m-%d %H:%M:%S.%3N' |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
my $input_format = DateTime::Format::Strptime->new( |
42
|
|
|
|
|
|
|
pattern => '%m/%d/%Y %H:%M:%S.%3N' |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
1
|
|
|
1
|
1
|
13
|
sub parse_datetime { shift; $output_format->parse_datetime(@_) } |
|
1
|
|
|
|
|
10
|
|
46
|
0
|
|
|
0
|
1
|
0
|
sub parse_timestamp { shift; $output_format->parse_datetime(@_) } |
|
0
|
|
|
|
|
0
|
|
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
1
|
1
|
11206
|
sub format_datetime { shift; $input_format->format_datetime(@_) } |
|
1
|
|
|
|
|
11
|
|
49
|
0
|
|
|
0
|
1
|
|
sub format_timestamp { shift; $input_format->format_datetime(@_) } |
|
0
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head1 METHODS |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=head2 parse_datetime |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
Parse a string returned by L for a C or C |
56
|
|
|
|
|
|
|
column in the C L format. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
Remember C fields have only minute precision. |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 parse_timestamp |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Same as L. |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
=head2 format_datetime |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
Format a L object into a string in the Sybase C C input |
67
|
|
|
|
|
|
|
format, with a time component, for insertion into the database. |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=head2 format_timestamp |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
Same as L. |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head1 AUTHOR |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
Rafael Kitover, C<< >> |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=head1 BUGS |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
80
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
81
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head1 SUPPORT |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
Other resources: |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
=over 4 |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
L |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
L |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=item * CPAN Ratings |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
L |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=item * Search CPAN |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
L |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=back |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Copyright (c) 2009-2011 Rafael Kitover |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
112
|
|
|
|
|
|
|
under the same terms as Perl itself. |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
=cut |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
1; # End of DateTime::Format::Sybase |