File: datesuffix

package info (click to toggle)
lists-archives 20000212-1
  • links: PTS
  • area: main
  • in suites: potato
  • size: 148 kB
  • ctags: 53
  • sloc: perl: 386; sh: 153; makefile: 42
file content (22 lines) | stat: -rwxr-xr-x 674 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/usr/bin/perl
use Time::Local;
require '/usr/share/mhonarc/mhtime.pl';
$y = shift if ($ARGV[0] eq '-y');
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) < 172800)   # more than three days difference
    {
        printf "%02d", $d[3] % 100;
        printf "%02d",($d[2]+1) if (!$y);
    }
    else
    {
        printf "%02d", (((localtime)[5] + 1900) % 100);
        printf "%02d", ((localtime)[4] + 1);
    }
}
else {
    printf "%02d", (((localtime)[5] + 1900) % 100);
    printf "%02d", ((localtime)[4] + 1);
}