From 85c516a86e3258c37dedcdf6b3c49a44a82cc96d Mon Sep 17 00:00:00 2001 From: barate Date: Mon, 28 Jan 2013 13:56:47 +0000 Subject: [PATCH] Replace calls to deprecated libbatch class Date by direct calls to localtime and strftime --- src/Launcher/BatchTest.cxx | 23 +++++++---------------- src/Launcher/Launcher.cxx | 1 - src/Launcher/Launcher_Job.cxx | 19 ++++++------------- src/Launcher/Launcher_Job.hxx | 1 - 4 files changed, 13 insertions(+), 31 deletions(-) diff --git a/src/Launcher/BatchTest.cxx b/src/Launcher/BatchTest.cxx index 63f0a53dd..80f15513a 100644 --- a/src/Launcher/BatchTest.cxx +++ b/src/Launcher/BatchTest.cxx @@ -24,7 +24,6 @@ #include "Launcher.hxx" #ifdef WITH_LIBBATCH -#include #include #endif @@ -42,24 +41,16 @@ BatchTest::BatchTest(const Engines::ResourceDefinition& batch_descr) _batch_descr = batch_descr; // Getting date - Batch::Date date = Batch::Date(time(0)); - _date = date.str(); - int lend = _date.size() ; - int i = 0 ; - while (i < lend) - { - if (_date[i] == '/' || _date[i] == '-' || _date[i] == ':' ) - { - _date[i] = '_' ; - } - i++ ; - } - + const size_t BUFSIZE = 32; + char date[BUFSIZE]; + time_t curtime = time(NULL); + strftime(date, BUFSIZE, "%Y_%m_%d__%H_%M_%S", localtime(&curtime)); + // Creating test temporary file _test_filename = "/tmp/"; - _test_filename += _date + "_test_cluster_file_"; + _test_filename += std::string(date) + "_test_cluster_file_"; _test_filename += _batch_descr.hostname.in(); - _base_filename = _date + "_test_cluster_file_" + _batch_descr.hostname.in(); + _base_filename = std::string(date) + "_test_cluster_file_" + _batch_descr.hostname.in(); #endif } diff --git a/src/Launcher/Launcher.cxx b/src/Launcher/Launcher.cxx index a690b48b5..f33eb976d 100644 --- a/src/Launcher/Launcher.cxx +++ b/src/Launcher/Launcher.cxx @@ -21,7 +21,6 @@ // #ifdef WITH_LIBBATCH -#include #include #include #include diff --git a/src/Launcher/Launcher_Job.cxx b/src/Launcher/Launcher_Job.cxx index f505b062e..b6744859c 100644 --- a/src/Launcher/Launcher_Job.cxx +++ b/src/Launcher/Launcher_Job.cxx @@ -467,19 +467,12 @@ Launcher::Job::common_job_params() // We define a default directory based on user time if (_work_directory == "") { - std::string thedate; - Batch::Date date = Batch::Date(time(0)); - thedate = date.str(); - int lend = thedate.size() ; - int i = 0 ; - while ( i < lend ) { - if ( thedate[i] == '/' || thedate[i] == '-' || thedate[i] == ':' ) { - thedate[i] = '_' ; - } - i++ ; - } - _work_directory = std::string("$HOME/Batch/"); - _work_directory += thedate; + const size_t BUFSIZE = 32; + char date[BUFSIZE]; + time_t curtime = time(NULL); + strftime(date, BUFSIZE, "%Y_%m_%d__%H_%M_%S", localtime(&curtime)); + _work_directory = std::string("$HOME/Batch/workdir_"); + _work_directory += date; } params[Batch::WORKDIR] = _work_directory; diff --git a/src/Launcher/Launcher_Job.hxx b/src/Launcher/Launcher_Job.hxx index 1a2fb230c..02b9d538a 100644 --- a/src/Launcher/Launcher_Job.hxx +++ b/src/Launcher/Launcher_Job.hxx @@ -39,7 +39,6 @@ #ifdef WITH_LIBBATCH #include -#include #include #include #endif -- 2.39.2