This file is indexed.

/usr/share/perl5/perl5i/1/DateTime.pm is in libperl5i-perl 2.13.2-1.

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
package perl5i::1::DateTime;

# A file to contain the Datetime work for perl5i to get it out of perl5i.pm

use 5.010;
use strict;
use warnings;

# Determine if we need Time::y2038 and only load if necessary.
# XXX This is a bit of a hack and should go into a config file.
use constant NEEDS_y2038 => (
    ((((CORE::gmtime(2**47-1))[5] || 0)      + 1900) != 4461763) ||
    ((((CORE::gmtime(-62135510400))[5] || 0) + 1900) != 1)
);

BEGIN {
    if( NEEDS_y2038 ) {
        require Time::y2038;
        Time::y2038->import;
    }
}


## no critic (Subroutines::ProhibitSubroutinePrototypes)
sub dt_gmtime (;$) {
    my $time = @_ ? shift : time;
    return gmtime($time) if wantarray;

    my($sec, $min, $hour, $mday, $mon, $year) = gmtime($time);
    $mon++;
    $year += 1900;

    require DateTime;
    return perl5i::1::DateTime::y2038->new(
        year            => $year,
        month           => $mon,
        day             => $mday,
        hour            => $hour,
        minute          => $min,
        second          => $sec,
        formatter       => "perl5i::1::DateTime::Format::CTime"
    );
}


sub _get_datetime_timezone {
    state $local_tzfile = "/etc/localtime";

    # Always be sure to honor the TZ environment var
    return "local" if $ENV{TZ};

    # Work around a bug in DateTime::TimeZone on FreeBSD where it
    # can't determine the time zone if /etc/localtime is not a link.
    # Tzfile is also faster to do localtime calculations.
    if( -e $local_tzfile ) {
        # Could go through more effort to figure it out.  Meh.
        my $tzname = "Local";
        if( -l $local_tzfile ) {
            if( my $real_tzfile = eval { readlink $local_tzfile } ) {
                $tzname = $real_tzfile;
            }
        }
        require DateTime::TimeZone::Tzfile;
        my $tz = DateTime::TimeZone::Tzfile->new(
            name     => $tzname,
            filename => $local_tzfile
        );
        return $tz if $tz;
    }

    return "local";
}

## no critic (Subroutines::ProhibitSubroutinePrototypes)
sub dt_localtime (;$) {
    my $time = @_ ? shift : time;
    return localtime($time) if wantarray;

    my($sec, $min, $hour, $mday, $mon, $year) = localtime($time);
    $mon++;
    $year += 1900;

    state $tz = _get_datetime_timezone();

    require DateTime;
    return perl5i::1::DateTime::y2038->new(
        year            => $year,
        month           => $mon,
        day             => $mday,
        hour            => $hour,
        minute          => $min,
        second          => $sec,
        time_zone       => $tz,
        formatter       => "perl5i::1::DateTime::Format::CTime"
    );
}


## no critic (Subroutines::ProhibitSubroutinePrototypes)
sub dt_time () {
    require DateTime::Format::Epoch;
    state $formatter = DateTime::Format::Epoch->new( epoch => DateTime->from_epoch( epoch => 0 ) );

    require DateTime;
    return perl5i::1::DateTime::time->from_epoch(
        epoch     => time,
        formatter => $formatter
    );
}


{
    package perl5i::1::DateTime::y2038;

    # Don't load DateTime until we need it.
    our @ISA = qw(DateTime);

    use overload
      "eq" => sub {
          my($dt1, $dt2) = @_;
          return "$dt1" eq "$dt2" if !eval { $dt2->isa("DateTime") };
          return $dt1 eq $dt2;
      };

    sub say {
        CORE::say("$_[0]");
    }

    sub print {
        CORE::print("$_[0]");
    }

    sub from_epoch {
        my $class = shift;

        if( perl5i::1::DateTime::NEEDS_y2038 ) {
            no warnings 'redefine';
            local *CORE::GLOBAL::gmtime    = \&Time::y2038::gmtime;
            local *CORE::GLOBAL::localtime = \&Time::y2038::localtime;

            return $class->SUPER::from_epoch(@_);
        }
        else {
            return $class->SUPER::from_epoch(@_);
        }
    }


    # Copy of DateTime's own epoch() function.
    if( perl5i::1::DateTime::NEEDS_y2038 ) {
        *epoch = sub {
            my $self = shift;

            my $zone = $self->time_zone;
            $self->set_time_zone("UTC");

            require Time::y2038;
            my $time = Time::y2038::timegm(
                $self->sec, $self->min, $self->hour, $self->mday,
                $self->mon - 1,
                $self->year - 1900,
            );

            $self->set_time_zone($zone);

            return $time;
        }
    }
}

{

    package perl5i::1::DateTime::time;

    use parent -norequire, qw(perl5i::1::DateTime::y2038);

    use overload
      "0+" => sub { $_[0]->epoch },
      "-"  => sub {
        my( $a, $b, $reverse ) = @_;

        if($reverse) {
            ( $b, $a ) = ( $a, $b );
        }

        my $time_a = eval { $a->isa("DateTime") } ? $a->epoch : $a;
        my $time_b = eval { $b->isa("DateTime") } ? $b->epoch : $b;

        return $time_a - $time_b;
      },

      "+" => sub {
        my( $a, $b, $reverse ) = @_;

        if($reverse) {
            ( $b, $a ) = ( $a, $b );
        }

        my $time_a = eval { $a->isa("DateTime") } ? $a->epoch : $a;
        my $time_b = eval { $b->isa("DateTime") } ? $b->epoch : $b;

        return $time_a + $time_b;
      },

      "==" => sub {
          my($a, $b) = @_;
          return $a+0 == $b+0 if !eval { $b->isa("DateTime") };
          return $a == $b;
      },

      fallback => 1;
}


{

    package perl5i::1::DateTime::Format::CTime;

    use CLASS;

    sub new {
        return bless {}, $CLASS;
    }

    sub format_datetime {
        my $self = shift;
        my $dt   = shift;

        # Straight from the Open Group asctime() docs.
        return sprintf "%.3s %.3s%3d %.2d:%.2d:%.2d %d",
          $dt->day_abbr,
          $dt->month_abbr,
          $dt->mday,
          $dt->hour,
          $dt->min,
          $dt->sec,
          $dt->year,
          ;
    }
}


1;