File: datesuffix

package info (click to toggle)
lists-archives 200100827-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 156 kB
  • ctags: 54
  • sloc: perl: 380; sh: 139; makefile: 42
file content (24 lines) | stat: -rwxr-xr-x 780 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/perl
use Time::Local;
use Getopt::Std;
require '/usr/share/mhonarc/mhtime.pl';
$|++;
getopts('dy');		# $opt_y => don't print year, #opt_d => disable time check
if (@d = &mhonarc::parse_date($l=<>)) {
    $currentTime = time;
    $receivedTime = timelocal($d[6],$d[5],$d[4],$d[1],$d[2],($d[3] < 1900 ? $d[3] : $d[3]- 1900));
    if((abs($currentTime - $receivedTime) < 259200) || $opt_d)   # more than three days difference
    {
        printf "%02d", $d[3] % 100;
        printf "%02d",($d[2]+1) if (!$opt_y);
    }
    else
    {
        printf "%02d", (((localtime)[5] + 1900) % 100);
        printf "%02d", ((localtime)[4] + 1) if (!$opt_y);
    }
}
else {
    printf "%02d", (((localtime)[5] + 1900) % 100);
    printf "%02d", ((localtime)[4] + 1) if (!$opt_y);
}