Thread [DOS-Batch] Berechneten Zeitraum in Batch einsetzen
(36 answers)
Opened by Frederick at 2012-09-02 14:26
delta.pl
Code (perl): (dl
)
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 #!/usr/bin/perl use strict; use warnings; use DateTime; #InputFormat: JJJJ.MM.DD-HH:MM:SS my $date=shift(@ARGV) // '2005.02.25-00:00:00'; my @date=$date=~/^\s*(\d{,4})\.(\d{,2})\.(\d{,2})(?:-(\d{,2}):(\d{,2}):(\d{,2}))$/; push(@date,0)while(@date<6); $date[0]+=1900 if(length($date[0])<3); $date[1]=1 if($date[1]<1); $date[2]=1 if($date[2]<1); my $past = DateTime->new( year => shift(@date), month => shift(@date), day => shift(@date), hour => shift(@date), minute => shift(@date), time_zone => 'Europe/Berlin', ); my $jetzt = DateTime->now(); my $delta = $jetzt->subtract_datetime_absolute($past); print $delta->in_units( 'seconds' ); batch: Code: (dl
)
1 SET diff=0 Last edited: 2012-09-04 16:02:38 +0200 (CEST) |