coolatt
February 10, 2010, 4:22am
1
Hi,
I need to search email files by date & time range in email files.
The timezone is not important.
Can someone plz advise how i can do this ?
For e.g A user can specify only
[1] A single date
[2] A date range
[3] date & time range
Below is part of the email file.
Received: from smtp.eds.mu (localhost [127.0.0.1])
by smtp.eds.mu (Postfix) with ESMTPA id 4E8B49683A7
for <xxxx@xxxx>; Mon, 8 Feb 2010 10:41:28 +0400 (MUT)
MIME-Version: 1.0
Date: Mon, 08 Feb 2010 10:41:28 +0400
From: xxxxxx <xxx.xxx@xxx.mu>
To: xxxxx <xxx@xxx.mu>
Subject: Some Subject
Basically you need to convert the date to Julian Days for a date range or convert date/time to epoch seconds. You can do everything with epoch seconds, even though it is a tad longer. I use seconds.
Do you have perl or do you need a C example? You can do Julian Day arithmetic in shell, but that doesn't solve the date/time issue.
coolatt
February 10, 2010, 4:45am
3
Basically you need to convert the date to Julian Days for a date range or convert date/time to epoch seconds. You can do everything with epoch seconds, even though it is a tad longer. I use seconds.
Do you have perl or do you need a C example? You can do Julian Day arithmetic in shell, but that doesn't solve the date/time issue.
Please provide a perl example
coolatt
February 11, 2010, 6:43am
4
can we use awk/sed to achieve this ??
---------- Post updated at 05:43 PM ---------- Previous update was at 03:52 PM ----------
Basically you need to convert the date to Julian Days for a date range or convert date/time to epoch seconds. You can do everything with epoch seconds, even though it is a tad longer. I use seconds.
Do you have perl or do you need a C example? You can do Julian Day arithmetic in shell, but that doesn't solve the date/time issue.
Will the following pseudocode work ?
start_epoch <= epoch(start date&time)
end_epoch <= epoch(end date&time)
mytimestamp <= get timestamp in file
mytimestamp_epoch <= epoch(mytimestamp)
if (mytimestamp_epoch >=start_epoch && mytimestamp_epoch <=end_epoch)
then
keep the file
end if
coolatt
February 15, 2010, 7:45am
5
Basically you need to convert the date to Julian Days for a date range or convert date/time to epoch seconds. You can do everything with epoch seconds, even though it is a tad longer. I use seconds.
Do you have perl or do you need a C example? You can do Julian Day arithmetic in shell, but that doesn't solve the date/time issue.
Yes, It works.
Thanks a lot.