Algorithm-Time-ToNumber
view release on metacpan or search on metacpan
lib/Algorithm/Time/ToNumber.pm view on Meta::CPAN
return sin($angle);
}
=head2 suricata_to_circle_day
Convert .timestamp from Suricata EVE output to a circle_day value based on
the day of week.
my $hour = 0;
while ($hour < 24) {
my $time = '2026-07-03T' . $hour . ':00:31.121465-0500';
my ($sin_angle, $cos_angle) = Algorithm::Time::ToNumber->suricata_to_circle_day($time);
print $time . ' ' . $sin_angle . ' ' . $cos_angle . "\n";
$hour++;
}
=cut
sub suricata_to_circle_day {
my ($class, $time) = @_;
my ($date) = $time =~ /^(\d{4}-\d{2}-\d{2})T/;
my $t = Time::Piece->strptime($date, '%Y-%m-%d');
return Algorithm::Time::ToNumber->circle_day($t->day_of_week);
}
=head2 suricata_to_angle_day
Convert .timestamp from Suricata EVE output to an angle_day value based on
the day of week.
my $hour = 0;
while ($hour < 24) {
my $time = '2026-07-03T' . $hour . ':00:31.121465-0500';
my $sin_angle = Algorithm::Time::ToNumber->suricata_to_angle_day($time);
print $time . ' ' . $sin_angle . "\n";
$hour++;
}
=cut
sub suricata_to_angle_day {
my ($class, $time) = @_;
my ($date) = $time =~ /^(\d{4}-\d{2}-\d{2})T/;
my $t = Time::Piece->strptime($date, '%Y-%m-%d');
return Algorithm::Time::ToNumber->angle_day($t->day_of_week);
}
=head2 suricata_to_circle_both
Convert .timestamp from Suricata EVE output to a sin/cos pair encoding both
the day of week and time of day as a single position within the week. The
week is treated as a 604800-second circle (7 days * 86400 seconds).
my $hour = 0;
while ($hour < 24) {
my $time = '2026-07-03T' . $hour . ':00:31.121465-0500';
my ($sin_angle, $cos_angle) = Algorithm::Time::ToNumber->suricata_to_circle_both($time);
print $time . ' ' . $sin_angle . ' ' . $cos_angle . "\n";
$hour++;
}
=cut
=head2 suricata_to_angle_both
Like suricata_to_circle_both, but returns only the sin value.
my $hour = 0;
while ($hour < 24) {
my $time = '2026-07-03T' . $hour . ':00:31.121465-0500';
my $sin_angle = Algorithm::Time::ToNumber->suricata_to_angle_both($time);
print $time . ' ' . $sin_angle . "\n";
$hour++;
}
=cut
=head1 AUTHOR
Zane C. Bowers-Hadley, C<< <vvelox at vvelox.net> >>
=head1 BUGS
Please report any bugs or feature requests to C<bug-algorithm-time-tonumber at rt.cpan.org>, or through
the web interface at L<https://rt.cpan.org/NoAuth/ReportBug.html?Queue=Algorithm-Time-ToNumber>. I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
=head1 SUPPORT
You can find documentation for this module with the perldoc command.
perldoc Algorithm::Time::ToNumber
You can also look for information at:
=over 4
=item * RT: CPAN's request tracker (report bugs here)
L<https://rt.cpan.org/NoAuth/Bugs.html?Dist=Algorithm-Time-ToNumber>
=item * CPAN Ratings
L<https://cpanratings.perl.org/d/Algorithm-Time-ToNumber>
( run in 1.950 second using v1.01-cache-2.11-cpan-6aa56a78535 )