TodayDir() function

Chuck Foster chuck.foster at STREAMSHIELD.COM
Thu Apr 7 17:27:38 IST 2005


    [ The following text is in the "iso-8859-1" character set. ]
    [ Your display is set for the "US-ASCII" character set.  ]
    [ Some characters may be displayed incorrectly. ]

Hi,

Finally had time to play with the new MailScanner code, and looked at the
changes made from below. One thing that I've realised now that I hadn't
before is that the originating time() value isn't being kept, which meant
that it wasn't available to my custom functions as I'd hoped - having to
parse the string to get the hours and minutes out is a bit painful!

A simple addition to the new function to keep that value would be very
useful; I used $dateval for that in my code:

  # Set the date string and number
  $this->{dateval} = time;
  $this->{datestring} = scalar localtime($this->{dateval});
  my ($day, $month, $year) = (localtime($this->dateval))[3,4,5];
  $this->{datenumber} = sprintf("%04d%02d%02d", $year+1900, $month+1, $day);

This also avoided the (very very slight!) situation where the day changes
between the setting of datestring and datenumber in the original code, which
both called a fresh time in localtime().


Also, there are a couple of points in the code that still call TodayDir() in
the archiving (Message.pm line 669,3982, MCPMessage.pm line 372) which could
conceivably end up with different dates - any plans to move those to
$this->{datenumber} too? (unless I missed something obvious!)

Best Wishes,
Chuck


-----Original Message-----
From: MailScanner mailing list [mailto:MAILSCANNER at JISCMAIL.AC.UK]On
Behalf Of Julian Field
Sent: 18 March 2005 17:30
To: MAILSCANNER at JISCMAIL.AC.UK
Subject: Re: TodayDir() function


Very good idea. I might do this over the weekend, but it certainly
should be in the next release.

Chuck Foster wrote:

>Hi,
>
>Sorry if this is a general discussion point, I hadn't spotted it in the
>archives as yet.
>
>There's a few places where TodayDir() gets called (and a couple where the
>date is still calculated manually); the function uses the current time on
>the server to generate the date string used, but this would mean that
>there's going to be the odd time (sorry!) when it will flick from 23:59:59
>to 00:00:00 whilst a message is being processed, so yielding two potential
>dates for where a file might be quarantined/archived.
>
>I think.
>
>Would it be more beneficial to record a message's "date" within the object
>itself, so that the same one could be used anywhere in the code relating to
>that message without having to re-calculate it and potentially get a
>different result? The reason this came up for me in the first place is that
>I do some housekeeping in a custom function, one of which was to work out
>where a quarantined message would be ... if the function is called on a
>different day then ... oops! Having a $m->{date} type variable would be
>quite invaluable!
>
>C:>
>
>
>This message should be regarded as confidential. If you have received this
>email in error please notify the sender and destroy it immediately.
>Statements of intent shall only become binding when confirmed in hard copy
>by an authorized signatory.
>
>
>--
>This message has been scanned for all known viruses
>and dangerous content by StreamShield Protector,
>and has been found to be clean.
>
>------------------------ MailScanner list ------------------------
>To unsubscribe, email jiscmail at jiscmail.ac.uk with the words:
>'leave mailscanner' in the body of the email.
>Before posting, read the MAQ (http://www.mailscanner.biz/maq/) and
>the archives (http://www.jiscmail.ac.uk/lists/mailscanner.html).
>
>Support MailScanner development - buy the book off the website!
>
>
>

--
Julian Field
www.MailScanner.info
MailScanner thanks transtec Computers for their support
Buy the MailScanner book at www.MailScanner.info/store

PGP footprint: EE81 D763 3DB0 0BFD E1DC 7222 11F6 5947 1415 B654

------------------------ MailScanner list ------------------------
To unsubscribe, email jiscmail at jiscmail.ac.uk with the words:
'leave mailscanner' in the body of the email.
Before posting, read the MAQ (http://www.mailscanner.biz/maq/) and
the archives (http://www.jiscmail.ac.uk/lists/mailscanner.html).

Support MailScanner development - buy the book off the website!

--
This message has been scanned for all known viruses
and dangerous content by StreamShield Protector,
and has been found to be clean.


This message should be regarded as confidential. If you have received this
email in error please notify the sender and destroy it immediately.
Statements of intent shall only become binding when confirmed in hard copy
by an authorized signatory.


--
This message has been scanned for viruses and potentially
harmful content by StreamShield Protector.

------------------------ MailScanner list ------------------------
To unsubscribe, email jiscmail at jiscmail.ac.uk with the words:
'leave mailscanner' in the body of the email.
Before posting, read the MAQ (http://www.mailscanner.biz/maq/) and
the archives (http://www.jiscmail.ac.uk/lists/mailscanner.html).

Support MailScanner development - buy the book off the website!




More information about the MailScanner mailing list