Dear Monks and Dudes...

I am trying to calculate the age of a log file. e.g.

The log file name will be in the format of 050927104522.log which is yymmddhhmmss.log

I need to check each log file and make sure that it is never 30 minutes old againts current date/time.

Explain:
Current datetime: 050927105522
List of log file: 050927104522.log,050927104222.log, 050927102022.log, 050927100000.log
Log file which is > 30 minutes old: 050927102022.log, 050927100000.log
(I need to remove those >30 minutes old)

I have a code (by pg) which gets current datetime and calculate the next 30 minutes

my $offset = 30; display(reverse((localtime(time()))[0 .. 5])); display(reverse((localtime(time() + 60 * $offset))[0 .. 5])); sub display { my @t = @_; printf("%d%02d%02d%02d%02d%02d\n", $t[0] + 1900, $t[1] + 1, @t +[2 .. 5]); }

How do i come about with this code where i can get the date from the log file name and add 30 minutes to it and compare againts the current date?

Cheers
Darren (Fellow Monk)


In reply to Time/date calculation by darrengan

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.