This file is indexed.

/usr/share/perl5/AAT/Datetime.pm is in octopussy 1.0.6-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# $HeadURL$
# $Revision: 535 $
# $Date: 2011-11-25 00:46:35 +0000 (Fri, 25 Nov 2011) $
# $Author: sebthebert $

=head1 NAME

AAT::Datetime - AAT Datetime module

=cut

package AAT::Datetime;

use strict;
use warnings;
use Readonly;

use Date::Manip;
use POSIX qw( strftime );

use AAT::Utils;

Readonly my @MONTH_NAME => (
  '',        '_JANUARY',   '_FEBRUARY', '_MARCH',
  '_APRIL',  '_MAY',       '_JUNE',     '_JULY',
  '_AUGUST', '_SEPTEMBER', '_OCTOBER',  '_NOVEMBER',
  '_DECEMBER',
);

Readonly my @WEEKDAY_NAME => (
  '',          '_MONDAY', '_TUESDAY',  '_WEDNESDAY',
  '_THURSDAY', '_FRIDAY', '_SATURDAY', '_SUNDAY',
);

Readonly my $MAX_HOURS    => 23;
Readonly my $MAX_MINUTES  => 59;
Readonly my $MAX_MONTH    => 12;
Readonly my $MAX_MONTHDAY => 31;
Readonly my $START_YEAR   => 1900;

=head1 FUNCTIONS

=head2 Month_Name($month)

Get the Month Name

Parameters:
 $month - Integer value of Month

Returns:
 $month_name - String value of Month

=cut

sub Month_Name
{
  my $month = shift;

  return ($MONTH_NAME[$month]);
}

=head2 Month_Nb_Days($year, $month)

Get the number of days in specified month

Parameters:
 $year - year
 $month - month

Returns:
 $daysinmonth - Number of days

=cut

sub Month_Nb_Days
{
  my ($year, $month) = @_;

  return (Date::Manip::Date_DaysInMonth($month, $year));
}


=head2 Delta

Returns Delta in minutes between 2 dates

=cut

sub Delta
{
  my ($date1, $date2) = @_;

  my $diff = Date::Manip::DateCalc(Date::Manip::ParseDate($date1), Date::Manip::ParseDate($date2));
  my $result = Date::Manip::Delta_Format($diff, 0, '%mt');    # delta in minutes

  if ($result =~ /^[-+]?(\d+)/) #\.\d*$/)
  {
    return ($1);
  }

  return (undef);
}

=head2 Seconds_Since_1970($year, $month, $day, $hour, $min)

Returns number of seconds since 1970

=cut

sub Seconds_Since_1970
{
  my ($year, $month, $day, $hour, $min) = @_;

  return (
    Date::Manip::Date_SecsSince1970GMT($month, $day, $year, $hour, $min, 0));

#return (Date::Manip::Date_SecsSince1970($month,$day,$year,$hour,$min, 0)) # GMT+3 fix
}


=head2 WeekDay($year, $month, $day)

Get the Day of Week (1 for Monday, 7 for Sunday)

Parameters:
 $year - year
 $month - month
 $day - day

Returns:
 $dayofweek - Day of Week

=cut

sub WeekDay
{
  my ($year, $month, $day) = @_;

	my $wday = strftime("%w", 0, 0, 0, $day, $month-1, $year-1900);
  $wday = ($wday == 0 ? 7 : $wday); # on Sunday we want 7 instead of 0
  
  return ($wday);
}

=head2 WeekDay_Name($wday)

Get the Day of Week

Parameters:
 $wday - Integer value of Day of Week

Returns:
 $weekday_name - String value of Day of Week

=cut

sub WeekDay_Name
{
  my $wday = shift;

  return ($WEEKDAY_NAME[$wday]);
}

=head2 YearWeek($year, $month, $day)

Get the Week of the Year

=cut

sub YearWeek
{
  my ($year, $month, $day) = @_;

  return (Date::Manip::Date_WeekOfYear($month, $day, $year, 1));
}

=head2 Current_Day()

Returns an Array of 2 hashrefs with the Begin & End of the Day
 
=cut

sub Current_Day
{
  my ($year, $month, $day, $hour, $min) = AAT::Utils::Now();

  my (%begin, %end) = ((), ());
  ($begin{year}, $begin{month}, $begin{day}) = ($year, $month, $day);
  ($begin{hour}, $begin{min}) = ('00', '00');
  ($end{year}, $end{month}, $end{day}) = ($year, $month, $day);
  ($end{hour}, $end{min}) = ($MAX_HOURS, $MAX_MINUTES);

  return (\%begin, \%end);
}

=head2 Current_Hour()

Returns an Array of 2 hashrefs with the Begin & End of the Hour

=cut

sub Current_Hour
{
  my ($year, $month, $day, $hour, $min) = AAT::Utils::Now();
  
  my (%begin, %end) = ((), ());
  ($begin{year}, $begin{month}, $begin{day}) = ($year, $month, $day);
  ($begin{hour}, $begin{min}) = (sprintf("%02d", $hour), '00');
  ($end{year}, $end{month}, $end{day}) = ($year, $month, $day);
  ($end{hour}, $end{min}) = (sprintf("%02d", $hour), $MAX_MINUTES);

  return (\%begin, \%end);
}

=head2 Current_Month()

Returns an Array of 2 hashrefs with the Begin & End of the Month

=cut

sub Current_Month
{
  my ($year, $month, $day, $hour, $min) = AAT::Utils::Now();

  my (%begin, %end) = ((), ());
  ($begin{year}, $begin{month}, $begin{day}) = ($year, sprintf("%02d", $month), '01');
  ($begin{hour}, $begin{min}) = ('00', '00');
  ($end{year}, $end{month}, $end{day}) = ($year, $month, $day);
  ($end{hour}, $end{min}) = ($MAX_HOURS, $MAX_MINUTES);

  return (\%begin, \%end);
}

=head2 Current_Week()

Returns an Array of 2 hashrefs with the Begin & End of the Week

=cut

sub Current_Week
{
  my ($year, $month, $day, $hour, $min) = AAT::Utils::Now();
  my $wday = WeekDay($year, $month, $day);
  $wday--;
  my $date = Date::Manip::DateCalc('today', "-${wday}day");
  my (%begin, %end) = ((), ());
  ($end{year}, $end{month}, $end{day}) = ($year, sprintf("%02d", $month), sprintf("%02d", $day));
  ($end{hour}, $end{min}) = ($MAX_HOURS, $MAX_MINUTES);
  ($year, $month, $day, $hour, $min) =
    Date::Manip::UnixDate($date, '%Y', '%f', '%e', '%k', '%M');
  ($begin{year}, $begin{month}, $begin{day}) = ($year, sprintf("%02d", $month), sprintf("%02d", $day));
  ($begin{hour}, $begin{min}) = ('00', '00');

  return (\%begin, \%end);
}

=head2 Current_Year()

Returns an Array of 2 hashrefs with the Begin & End of the Year

=cut

sub Current_Year
{
  my ($year, $month, $day, $hour, $min) = AAT::Utils::Now();

  my (%begin, %end) = ((), ());
  ($begin{year}, $begin{month}, $begin{day}) = ($year, '01', '01');
  ($begin{hour}, $begin{min}) = ('00', '00');
  ($end{year}, $end{month}, $end{day}) = ($year, sprintf("%02d", $month), sprintf("%02d", $day));
  ($end{hour}, $end{min}) = ($MAX_HOURS, $MAX_MINUTES);

  return (\%begin, \%end);
}

=head2 Last_Day()

Returns an Array of 2 hashrefs with the Begin & End of the Last/Previous Day

=cut

sub Last_Day
{
  my $date = Date::Manip::ParseDate('yesterday');
  my ($year, $month, $day, $hour, $min) =
    Date::Manip::UnixDate($date, '%Y', '%f', '%e', '%k', '%M');

  my (%begin, %end) = ((), ());
  ($begin{year}, $begin{month}, $begin{day}) = ($year, sprintf("%02d", $month), sprintf("%02d", $day));
  ($begin{hour}, $begin{min}) = ('00', '00');
  ($end{year}, $end{month}, $end{day}) = ($year, sprintf("%02d", $month), sprintf("%02d", $day));
  ($end{hour}, $end{min}) = ($MAX_HOURS, $MAX_MINUTES);

  return (\%begin, \%end);
}

=head2 Last_Hour()

Returns an Array of 2 hashrefs with the Begin & End of the Last/Previous Hour

=cut

sub Last_Hour
{
  my $date = Date::Manip::DateCalc('now', '-1hour');
  my ($year, $month, $day, $hour, $min) =
    Date::Manip::UnixDate($date, '%Y', '%f', '%e', '%k', '%M');

  my (%begin, %end) = ((), ());
  ($begin{year}, $begin{month}, $begin{day}) = ($year, sprintf("%02d", $month), sprintf("%02d", $day));
  ($begin{hour}, $begin{min}) = (sprintf("%02d", $hour), '00');
  ($end{year}, $end{month}, $end{day}) = ($year, sprintf("%02d", $month), sprintf("%02d", $day));
  ($end{hour}, $end{min}) = (sprintf("%02d", $hour), $MAX_MINUTES);

  return (\%begin, \%end);
}

=head2 Last_Month()

Returns an Array of 2 hashrefs with the Begin & End of the Last/Previous Month

=cut

sub Last_Month
{
  my $date = Date::Manip::DateCalc('today', '-1month');
  my ($year, $month, $day, $hour, $min) =
    Date::Manip::UnixDate($date, '%Y', '%f', '%e', '%k', '%M');

  my (%begin, %end) = ((), ());
  ($begin{year}, $begin{month}, $begin{day}) = ($year, sprintf("%02d", $month), '01');
  ($begin{hour}, $begin{min}) = ('00', '00');
  ($end{year}, $end{month}, $end{day}) =
    ($year, sprintf("%02d", $month), Month_Nb_Days($year, $month));
  ($end{hour}, $end{min}) = ($MAX_HOURS, $MAX_MINUTES);

  return (\%begin, \%end);
}

=head2 Last_Week()

Returns an Array of 2 hashrefs with the Begin & End of the Last/Previous Week

=cut

sub Last_Week
{
  my ($year, $month, $day, $hour, $min) = AAT::Utils::Now();
  my $wday = WeekDay($year, $month, $day);
  $wday--;
  my $date = Date::Manip::DateCalc('today', "-1week -${wday}day");
  my (%begin, %end) = ((), ());
  ($year, $month, $day, $hour, $min) =
    Date::Manip::UnixDate($date, '%Y', '%f', '%e', '%k', '%M');
  ($begin{year}, $begin{month}, $begin{day}) = ($year, sprintf("%02d", $month), sprintf("%02d", $day));
  ($begin{hour}, $begin{min}) = ('00', '00');
  $date = Date::Manip::DateCalc($date, '+6days');
  ($year, $month, $day, $hour, $min) =
    Date::Manip::UnixDate($date, '%Y', '%f', '%e', '%k', '%M');
  ($end{year}, $end{month}, $end{day}) = ($year, sprintf("%02d", $month), sprintf("%02d", $day));
  ($end{hour}, $end{min}) = ($MAX_HOURS, $MAX_MINUTES);

  return (\%begin, \%end);
}

=head2 Last_Year()

Returns an Array of 2 hashrefs with the Begin & End of the Last/Previous Year

=cut

sub Last_Year
{
  my ($year, $month, $day, $hour, $min) = AAT::Utils::Now();

  my (%begin, %end) = ((), ());
  ($begin{year}, $begin{month}, $begin{day}) = ($year - 1, '01', '01');
  ($begin{hour}, $begin{min}) = ('00', '00');
  ($end{year}, $end{month}, $end{day}) = ($year - 1, $MAX_MONTH, $MAX_MONTHDAY);
  ($end{hour}, $end{min}) = ($MAX_HOURS, $MAX_MINUTES);

  return (\%begin, \%end);
}

1;

=head1 AUTHOR

Sebastien Thebert <octo.devel@gmail.com>

=cut