aboutsummaryrefslogtreecommitdiff
path: root/lib/Net/Hawk/Utils.pm
blob: 2b500434dc5c9eba3be3bf9ad379c1035b625e3c (plain)
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
package Net::Hawk::Utils; 
use strict;
use warnings;
use Time::HiRes qw(gettimeofday);
use 5.010;
use Moo;
 
sub parse_content_type {
    my ($self,$header) = @_;
    return '' unless defined $header;
 
    my ($ret) = $header =~ m{^\s*(\S+?)\s*(;|$)};
    return lc($ret);
}
 
sub now_msecs {
    my ($self,$offset_ms) = @_;
 
    my ($sec,$usec) = gettimeofday;
    return $sec + int($usec/1000) + $offset_ms//0;
}
 
sub now_secs {
    my ($self,$offset_ms) = @_;
 
    return int(now_msecs($offset_ms)/1000);
}
 
1;