Debian Codegraph @

lib/Date/Manip/Interfaces.pod

raw
1 # Copyright (c) 1995-2026 Sullivan Beck. All rights reserved.
2 # This program is free software; you can redistribute it and/or modify it
3 # under the same terms as Perl itself.
4
5 =pod
6
7 =head1 NAME
8
9 Date::Manip::Interfaces - A description of functional and OO interfaces
10
11 =head1 DESCRIPTION
12
13 There are three different ways to use Date::Manip . A complete description
14 of each is included below. They are:
15
16 =over 4
17
18 =item Functional interface (version 5)
19
20 Date::Manip version 5 runs on very old versions of perl. If you need
21 to use Date::Manip with a version of perl older than 5.10, this is the
22 only interface available.
23
24 =item Functional interface (version 6)
25
26 When Date::Manip was rewritten (version 6), it made use of some features
27 of perl 5.10 . This is the recommended interface if you are supporting
28 a script that uses the functional interface, but where a newer version
29 of perl is available.
30
31 =item Object-oriented interface
32
33 The OO interface is the recommended interface wherever possible. It
34 is the only one with access to the full functionality of the module.
35
36 =back
37
38 =head1 VERSION 5 AND VERSION 6
39
40 Date::Manip version 5.xx was available for many years, but suffered
41 from several weaknesses. It was slow, and did not handle timezones
42 or daylight saving time correctly. It was written as a functional
43 interface, even though an object-oriented interface would have been
44 better. It did have the advantage of running on very old versions of
45 perl (it is known to work on perl 5.6 and may work on even older
46 versions of perl).
47
48 Date::Manip version 6.00 was a complete rewrite of the module. For
49 detailed information about the differences, please refer to the
50 L<Date::Manip::Changes5to6> document. The rewrite was needed in order
51 to handle timezone operations, in addition to many other improvements
52 including much better performance and more robust parsing.
53
54 The rewrite made use of features introduced in perl 5.10 which made
55 the date parsing routines significantly cleaner. In addition, the
56 6.xx release was written as an object oriented set of modules which
57 are much more powerful than the older functional interface. For
58 backward compatibility, a new functional interface was rewritten
59 (which is simply a set of wrapper functions which call the OO methods)
60 which is almost entirely backward compatible with the version 5.xx
61 interface.
62
63 The Date::Manip distribution includes all three of these interfaces:
64 the older version 5 interface, and both the new OO interface and
65 the backward compatible functional interface. Also, all three are
66 installed, so you can use whichever interface is appropriate.
67
68 Since there are three different interfaces available, choosing the
69 interface is the necessary.
70
71 If you are running on a system with a very old version of perl (older than
72 5.10), the version 5 interface is your only option.
73
74 If you are on a system running a newer version of perl, but need to
75 support a script that was written using the functional interface, then
76 you can use the version 6 functional interface.
77
78 For everyone else, it is strongly recommended that you use the object-oriented
79 interface.
80
81 A more detailed description of each interface is included below. If
82 you already know which interface you want to use, just go to the
83 L<Date::Manip/"SEE ALSO"> section for documentation for each
84 interface.
85
86 =head1 FUNCTIONAL INTERFACE (VERSION 5)
87
88 When using a version of perl older than 5.10, this is the only
89 interface available. This interface is documented in the
90 L<Date::Manip::DM5> document. This interface has several weaknesses that
91 need to be understood when using it:
92
93 =over 4
94
95 =item B<Limited Support>
96
97 The version 5 functional interface is no longer being developed, and
98 only limited support is available for it.
99
100 As of December 2012, no development will be done, and I will not
101 correct any remaining bugs in version 5. If a patch is supplied by
102 someone else to fix bugs, I will apply it, provided it applies
103 cleanly, and the resulting code continues to pass all tests. I will
104 not apply patches to add features.
105
106 I intend to remove this in version 7.00.
107
108 =item B<Limited Time Zone Support>
109
110 Time zone support is extremely limited, and is often incorrect. The lack
111 of time zone support was the primary reason for rewriting Date::Manip.
112
113 The version 5 interface does not handle daylight saving time changes
114 correctly.
115
116 =item B<Performance Issues>
117
118 Considerable time has been spent speeding up Date::Manip, and fairly
119 simple benchmarks show that version 6 is around twice as fast as
120 version 5.
121
122 =back
123
124 Feel free to email me concerns and comments.
125
126 =head1 FUNCTIONAL INTERFACE (VERSION 6)
127
128 The version 6 functional interface is almost completely identical to
129 the version 5 functional interface, except that it uses the
130 object-oriented modules to do all the real work.
131
132 Time zone support is greatly improved, but is still somewhat limited.
133 Since the version 6 interface is backward compatible, dates do not
134 store time zone information in them, so the programmer is responsible
135 for keeping track of what time zone each date is in. If you want full
136 access to the time zone support offered in Date::Manip, you have to
137 use the object-oriented interface.
138
139 For the most part, scripts written for older versions of Date::Manip
140 will continue to work (and scripts written for the version 6
141 functional interface will run with the version 5 interface), however
142 in a few cases, you may need to modify your scripts. Please refer to
143 the L<Date::Manip::Migration5to6> document for a list of changes which
144 may be necessary.
145
146 =head1 OBJECT-ORIENTED INTERFACE
147
148 As of 6.00, Date::Manip consists of a set of OO modules. Each have
149 their own document (see the L<Date::Manip/"SEE ALSO"> section).
150
151 The OO interface consists of the following modules: L<Date::Manip::Date>,
152 L<Date::Manip::Delta>, L<Date::Manip::Recur>, L<Date::Manip::TZ>, and
153 L<Date::Manip::Base>.
154
155 The object-oriented interface is the only way to get the full
156 functionality of Date::Manip. It fully support time zones (and
157 daylight saving time).
158
159 =head1 SELECTING AN INTERFACE
160
161 If you are running an older version of perl, the version 5 functional
162 interface is the only one available to you, and it will automatically
163 be used.
164
165 If you are running a newer version of perl (5.10 or higher), you can
166 use the object-oriented modules by loading them directly, or you can
167 use a functional interface.
168
169 If you use a functional interface, it will default to the version 6
170 interface, but you can choose to run the version 5 interface in one
171 of three ways:
172
173 =over 4
174
175 =item Using the OO interface
176
177 By including any of the following:
178
179 use Date::Manip::Date;
180 use Date::Manip::Delta;
181 use Date::Manip::Recur;
182 use Date::Manip::TZ;
183 use Date::Manip::Base;
184
185 you have access to the OO interface for the appropriate types of objects.
186
187 =item Use the default functional interface
188
189 By including:
190
191 use Date::Manip;
192
193 in your script, one of the functional interfaces will be loaded. If you
194 are running a version of perl older than 5.10, it will automatically be
195 the version 5 interface. If you are running a newer version of perl,
196 it will automatically load the version 6 interface.
197
198 =item DATE_MANIP environment variable
199
200 By setting the DATE_MANIP environment variable to 'DM5' before running
201 the perl script, the version 5 interface will be used.
202
203 =item Date::Manip::Backend variable
204
205 Alternately, you can set the Date::Manip::Backend variable to be 'DM5'
206 before loading the module. Typically, this will be done in the following
207 way:
208
209 BEGIN {
210 $Date::Manip::Backend = 'DM5';
211 }
212 use Date::Manip;
213
214 =back
215
216 Once a functional interface is loaded, you cannot switch between the
217 version 5 and version 6 interfaces.
218
219 =head1 SEE ALSO
220
221 Date::Manip - main module documentation
222
223 =head1 LICENSE
224
225 This script is free software; you can redistribute it and/or
226 modify it under the same terms as Perl itself.
227
228 =head1 AUTHOR
229
230 Sullivan Beck ([email protected])
231
232 =cut