Commit c97ecf51 authored by Leigh Stoller's avatar Leigh Stoller

Move TBDateStringGMT and TBDateStringLocal over to emutil to avoid

port problem on ops.
parent bbb6d80d
......@@ -33,12 +33,13 @@ use vars qw(@ISA @EXPORT);
TBDB_CHECKDBSLOT_ERROR TBcheck_dbslot TBFieldErrorString
TBGetUniqueIndex ParRun VersionInfo UpdateVersionInfo
SpanningTree GenFakeMac BackTraceOnWarning PassWordHash
SSHwithTimeout
SSHwithTimeout TBDateStringGMT TBDateStringLocal
);
use emdb;
use English;
use Carp;
use Date::Parse;
# Configure variables.
my $TB = "@prefix@";
......@@ -741,6 +742,32 @@ sub GenHash()
return $hash;
}
# Convert date to GMT
sub TBDateStringGMT($)
{
my ($date) = @_;
return ""
if (!defined($date) || "$date" eq "");
if ($date !~ /^\d$/) {
$date = str2time($date);
}
return POSIX::strftime("20%y-%m-%dT%H:%M:%SZ", gmtime($date));
}
# Convert date to Local
sub TBDateStringLocal($)
{
my ($date) = @_;
return ""
if (!defined($date) || "$date" eq "");
if ($date !~ /^\d*$/) {
$date = timelocal(strptime($date));
}
return POSIX::strftime("20%y-%m-%d %H:%M:%S", localtime($date));
}
# _Always_ make sure that this 1 is at the end of the file...
1;
......@@ -37,14 +37,13 @@ use Exporter;
TBSCRIPTLOCK_IGNORE TBSCRIPTLOCK_FAILED
PROJROOT GROUPROOT USERROOT SCRATCHROOT SHAREROOT
TBValidUserDir TBValidUserDirList TBMakeTempFile NewUUID System
SendProjAdminMail ReOpenLog TBDateStringGMT TBDateStringLocal
SendProjAdminMail ReOpenLog
CheckDaemonRunning MarkDaemonRunning MarkDaemonStopped);
# After package decl.
use English;
use POSIX qw(strftime);
use POSIX qw(setsid);
use Date::Parse;
use Time::Local;
use Fcntl;
use Fcntl ':flock';
......@@ -333,33 +332,6 @@ sub TBDateTimeFSSafe()
return POSIX::strftime("20%y%m%d-%H.%M.%S", localtime());
}
# Convert date to GMT
sub TBDateStringGMT($)
{
my ($date) = @_;
return ""
if (!defined($date) || "$date" eq "");
if ($date !~ /^\d$/) {
$date = str2time($date);
}
return POSIX::strftime("20%y-%m-%dT%H:%M:%SZ", gmtime($date));
}
# Convert date to Local
sub TBDateStringLocal($)
{
my ($date) = @_;
return ""
if (!defined($date) || "$date" eq "");
if ($date !~ /^\d*$/) {
$date = timelocal(strptime($date));
}
return POSIX::strftime("20%y-%m-%d %H:%M:%S", localtime($date));
}
#
# Print out a timestamp if the TIMESTAMPS configure variable was set.
#
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment