Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
emulab-stable
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
emulab
emulab-stable
Commits
c97ecf51
Commit
c97ecf51
authored
Oct 28, 2014
by
Leigh B Stoller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move TBDateStringGMT and TBDateStringLocal over to emutil to avoid
port problem on ops.
parent
bbb6d80d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
29 additions
and
30 deletions
+29
-30
db/emutil.pm.in
db/emutil.pm.in
+28
-1
tbsetup/libtestbed.pm.in
tbsetup/libtestbed.pm.in
+1
-29
No files found.
db/emutil.pm.in
View file @
c97ecf51
...
...
@@ -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;
tbsetup/libtestbed.pm.in
View file @
c97ecf51
...
...
@@ -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
.
#
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment