pauld wrote:
>
im importing data from an excel spreadsheet into an array of hashes.
the date is initially converted using Date::Format::Excel.

for this bit

{START} = unix start time .{START_DS} = string that I use to convert
to unixtime with

my $var=0;my [EMAIL PROTECTED];
while ($var<$va_length)
{
print "${$daylistsorted[$var]}{TH} ";
print   'from ';
print ${$daylistsorted[$var]}{START};
print ' to '.${$daylistsorted[$var]}{END_DS};
print "   duration  ";print   int((${$daylistsorted[$var]}{END}-$
{$daylistsorted[$var]}{START})/60);

if (exists(  ${$daylistsorted[$var+1]}{TH}  )   )
         {
print "\tinterval to next start "; print int ((${$daylistsorted[$var
+1]}{START}-${$daylistsorted[$var]}{END})/60);print " \n";
         }
$var++;
}                        }

Sat  04-08-2007
=========================
1 from 1186220100 to 2007:08:04 10:33   duration  58 interval to next
start 34
4 from 1186225620 to 2007:08:04 13:29   duration  142  interval to
next start 26

and when i change it to
#print ${$daylistsorted[$var]}{START};
print UnixDate(${$daylistsorted[$var]}{START}, '%Y:%m:%d %H:%M');

 I get this

Sat  04-08-2007
=========================
 1 from  to 2007:08:04 10:33   duration  58   interval to next start
34
 4 from  to 2007:08:04 13:29   duration  142  interval to next start
26


with both dates as strings


Sat  04-08-2007
=========================
1 from 2007:08:04 09:35 to 2007:08:04 10:33   duration  58   interval
to next start 34
4 from 2007:08:04 11:07 to 2007:08:04 13:29   duration  142  interval
to next start 26

Your START and END fields appear to be seconds since epoch, whereas the
END_DS field is in the form '%Y:%m:%d %H:%M' as you described in your
earlier post. Neither of these are anything to do with the Date::Manip
module and consequently the answers you have had were irrelevant.

To display a time value such as this in a custom format you can use the
strftime() function from the POSIX module. The program below exemplifies
this.

However, unless I am misunderstanding you you already have the START
time as a string in START_DS. Isn't this sufficient?

HTH,

Rob



use strict;
use warnings;

use POSIX qw(strftime);

my $date_time = 1186220100;

print strftime('%Y:%m:%d %H:%M', localtime($date_time));

**OUTPUT**

2007:08:04 10:35

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to