This file is indexed.

/usr/share/perl5/NetSDS/Util/DateTime.pm is in libnetsds-util-perl 1.044-2.

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
#===============================================================================
#
#         FILE:  DateTime.pm
#
#  DESCRIPTION:  Common date/time processing utilities for NetSDS
#
#       AUTHOR:  Michael Bochkaryov (Rattler), <misha@rattler.kiev.ua>
#      COMPANY:  Net.Style
#      CREATED:  25.04.2008 15:55:01 EEST
#===============================================================================

=head1 NAME

NetSDS::Util::DateTime - common date/time processing routines

=head1 SYNOPSIS

	use NetSDS::Util::DateTime;

	print "Current date: " . date_now();

=head1 DESCRIPTION

This package provides set of routines for date and time processing.

=cut

package NetSDS::Util::DateTime;

use 5.8.0;
use strict;
use warnings;

use base 'Exporter';

use version; our $VERSION = '1.044';

our @EXPORT = qw(
  date_now_array
  date_now
  date_now_iso8601
  date_strip
  date_date
  date_time
  time_from_string
  date_from_string
  date_inc
  date_inc_string
);

use POSIX;
use Time::Local;
use Time::HiRes qw(gettimeofday clock_gettime);

# Include parsing/formatting modules
use HTTP::Date qw(parse_date);
use Date::Parse qw(str2time);
use Date::Format qw(time2str);

#===============================================================================

=head1 EXPORTED FUNCTIONS

=over

=item B<date_now_array([TIME])>

Returns array of date items for given date.
If source date is not set current date used.

=cut

#-----------------------------------------------------------------------
sub date_now_array {
	my ( $sec, $min, $hor, $mdy, $mon, $yer ) = localtime( (@_) ? $_[0] : time );

	return ( $yer + 1900, $mon + 1, $mdy, $hor, $min, $sec );
}

#***********************************************************************

=item B<date_now([TIME])>

Return [given] date as string.

    2001-12-23 14:39:53

=cut

#-----------------------------------------------------------------------
sub date_now {
	my ( $tm, $zn ) = @_;

	return ($zn)
	  ? time2str( "%Y-%m-%d %T %z", $tm || time )
	  : time2str( "%Y-%m-%d %T", $tm || time );
}

#***********************************************************************

=item B<date_now_iso8601([TIME])>

Return date as ISO 8601 string.

    20011223T14:39:53Z

L<http://en.wikipedia.org/wiki/ISO_8601>
L<http://www.w3.org/TR/NOTE-datetime>

=cut

#-----------------------------------------------------------------------
sub date_now_iso8601 {
	my ($tm) = @_;

	return time2str( "%Y%m%dT%H%M%S%z", $tm || time );
}

#***********************************************************************

=item B<date_strip(DATE)>

Trim miliseconds from date.

=cut

#-----------------------------------------------------------------------
sub date_strip {
	my ($date) = @_;

	$date =~ s/\.\d+// if ($date);

	return $date;
}

#***********************************************************************

=item B<date_date(DATE)>

Trim time part from date.

=cut

#-----------------------------------------------------------------------
sub date_date {
	my ($date) = @_;

	$date =~ s/[\sT]+.+$// if ($date);

	return $date;
}
#***********************************************************************

=item B<date_time(DATE)>

Trim date part from date.

=cut

#-----------------------------------------------------------------------

sub date_time { 
	my ($date) = @_; 

	unless ( defined ($date) ) { 
		return undef; 
	}

	my ($dateonly, $time) = split (/ /, $date); 

	return $time; 
} 

#***********************************************************************

=item B<time_from_string($string)>

Return parsed date/time structure.

=cut

#-----------------------------------------------------------------------
sub time_from_string {
	my ($str) = @_;

	unless ($str) {
		return undef;
	}

	my $tm = Date::Parse::str2time($str);
	if ($tm) {
		return $tm;
	}

	$tm = parse_date($str);
	if ($tm) {
		return Date::Parse::str2time($tm);
	}

	return undef;
}

#***********************************************************************

=item B<date_from_string($string)>

Return date from string representation.

=cut

#-----------------------------------------------------------------------
sub date_from_string {
	my ($str) = @_;

	return date_now( time_from_string($str) );
}

#***********************************************************************

=item B<date_inc([INCREMENT, [TIME]])>

Return date incremented with given number of seconds.

=cut

#-----------------------------------------------------------------------
sub date_inc {
	my ( $inc, $tm ) = @_;
	$tm ||= time;

	return date_now( $tm + $inc );
}

#***********************************************************************

=item B<date_inc_string([INCREMENT, [TIME]])>

Return string representation of date incremented with given number of seconds.

=cut

#-----------------------------------------------------------------------
sub date_inc_string {
	my ( $inc, $tm ) = @_;

	return ($tm) ? date_inc( $inc, time_from_string($tm) ) : date_inc($inc);
}

1;

__END__

=back

=head1 EXAMPLES

None yet

=head1 BUGS

Unknown yet

=head1 SEE ALSO

L<Date::Parse>, L<Date::Format>

=head1 TODO

Import stuff from Wono project

=head1 AUTHOR

Valentyn Solomko <val@pere.org.ua>

Michael Bochkaryov <misha@rattler.kiev.ua>

=cut