aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Mike Kelly <pioto@pioto.org> 2009-10-15 12:14:12 -0400
committerAvatar Mike Kelly <pioto@pioto.org> 2009-10-15 13:48:44 -0400
commit5d0dd77eec2d53bf300ee8216c4023aea58ffcaf (patch)
treea7544331c3ee6d14e1d8539cbb191538acdca37e
parent6f41065c96a93c30d366eac1adc85cb325cb7e43 (diff)
downloadpaludis-5d0dd77eec2d53bf300ee8216c4023aea58ffcaf.tar.gz
paludis-5d0dd77eec2d53bf300ee8216c4023aea58ffcaf.tar.xz
Use pretty_print_time() instead of gmtime hax.
Fixes: ticket:751
-rw-r--r--doc/api/cplusplus/examples/example_metadata_key.cc9
-rw-r--r--src/clients/accerso/accerso.cc8
-rw-r--r--src/clients/cave/cmd_show.cc7
-rw-r--r--src/clients/instruo/instruo.cc8
-rw-r--r--src/clients/paludis/info.cc9
-rw-r--r--src/output/console_query_task.cc10
-rw-r--r--src/output/mask_displayer.cc7
7 files changed, 17 insertions, 41 deletions
diff --git a/doc/api/cplusplus/examples/example_metadata_key.cc b/doc/api/cplusplus/examples/example_metadata_key.cc
index 9ba53f8..4d313f5 100644
--- a/doc/api/cplusplus/examples/example_metadata_key.cc
+++ b/doc/api/cplusplus/examples/example_metadata_key.cc
@@ -14,11 +14,11 @@
*/
#include <paludis/paludis.hh>
+#include <paludis/util/pretty_print.hh>
#include "example_command_line.hh"
#include <iostream>
#include <iomanip>
#include <set>
-#include <time.h>
using namespace paludis;
using namespace examples;
@@ -92,12 +92,7 @@ namespace
{
cout << indent << left << setw(30) << " Class:" << " " << "MetadataTimeKey" << endl;
- /* Yay horrible C formatting routines! */
- time_t t(key.value());
- char buf[255];
- if (! strftime(buf, 254, "%c", gmtime(&t)))
- buf[0] = '\0';
- cout << indent << left << setw(30) << " Value:" << " " << buf << endl;
+ cout << indent << left << setw(30) << " Value:" << " " << pretty_print_time(key.value()) << endl;
}
void visit(const MetadataValueKey<std::tr1::shared_ptr<const Contents> > &)
diff --git a/src/clients/accerso/accerso.cc b/src/clients/accerso/accerso.cc
index 8a03bf3..116974f 100644
--- a/src/clients/accerso/accerso.cc
+++ b/src/clients/accerso/accerso.cc
@@ -31,6 +31,7 @@
#include <paludis/util/map.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/make_shared_ptr.hh>
+#include <paludis/util/pretty_print.hh>
#include <paludis/standard_output_manager.hh>
#include <paludis/util/safe_ofstream.hh>
#include <paludis/create_output_manager_info.hh>
@@ -208,13 +209,8 @@ main(int argc, char *argv[])
std::ostream & out(outf ? *outf : cout);
- char t[255];
- time_t tt(time(0));
- if (0 == strftime(t, 255, "%c", gmtime(&tt)))
- throw InternalError(PALUDIS_HERE, "strftime failed");
-
out << colour(cl_heading, "Accerso results for ") << colour(cl_repository_name, env.main_repository()->name())
- << colour(cl_heading, " on " + stringify(t) + ":") << endl << endl
+ << colour(cl_heading, " on " + pretty_print_time(time(0)) + ":") << endl << endl
<< total << " IDs, " << success << " successes, " << (total - success) << " failures" << endl << endl;
int exit_status(0);
diff --git a/src/clients/cave/cmd_show.cc b/src/clients/cave/cmd_show.cc
index f779e1a..50e32ba 100644
--- a/src/clients/cave/cmd_show.cc
+++ b/src/clients/cave/cmd_show.cc
@@ -41,6 +41,7 @@
#include <paludis/util/make_shared_ptr.hh>
#include <paludis/util/simple_visitor_cast.hh>
#include <paludis/util/indirect_iterator-impl.hh>
+#include <paludis/util/pretty_print.hh>
#include <paludis/action.hh>
#include <paludis/mask.hh>
#include <paludis/choice.hh>
@@ -587,12 +588,8 @@ namespace
void visit(const MetadataTimeKey & k)
{
- char buf[255];
- time_t t(k.value());
- if (! strftime(buf, 255, "%c", gmtime(&t)))
- buf[0] = '\0';
cout << format_general_rhvib(f::show_metadata_key_value(), k.raw_name(), k.human_name(),
- std::string(buf), indent, important);
+ pretty_print_time(k.value()), indent, important);
}
};
diff --git a/src/clients/instruo/instruo.cc b/src/clients/instruo/instruo.cc
index cee8dec..b517774 100644
--- a/src/clients/instruo/instruo.cc
+++ b/src/clients/instruo/instruo.cc
@@ -40,6 +40,7 @@
#include <paludis/util/thread_pool.hh>
#include <paludis/util/destringify.hh>
#include <paludis/util/safe_ofstream.hh>
+#include <paludis/util/pretty_print.hh>
#include <paludis/environments/no_config/no_config_environment.hh>
#include <paludis/package_database.hh>
#include <paludis/metadata_key.hh>
@@ -359,13 +360,8 @@ main(int argc, char *argv[])
std::ostream & out(outf ? *outf : cout);
- char t[255];
- time_t tt(time(0));
- if (0 == strftime(t, 255, "%c", gmtime(&tt)))
- throw InternalError(PALUDIS_HERE, "strftime failed");
-
out << colour(cl_heading, "Instruo results for ") << colour(cl_repository_name, env.main_repository()->name())
- << colour(cl_heading, " on " + stringify(t) + ":") << endl << endl
+ << colour(cl_heading, " on " + pretty_print_time(time(0)) + ":") << endl << endl
<< total << " IDs, " << success << " successes, " << (total - success) << " failures" << endl << endl;
int exit_status(0);
diff --git a/src/clients/paludis/info.cc b/src/clients/paludis/info.cc
index 2a77180..ab8df99 100644
--- a/src/clients/paludis/info.cc
+++ b/src/clients/paludis/info.cc
@@ -27,6 +27,7 @@
#include <paludis/util/simple_visitor_cast.hh>
#include <paludis/util/make_named_values.hh>
#include <paludis/util/system.hh>
+#include <paludis/util/pretty_print.hh>
#include <paludis/package_database.hh>
#include <paludis/environment.hh>
#include <paludis/package_id.hh>
@@ -131,12 +132,8 @@ namespace
void visit(const MetadataTimeKey & k)
{
- time_t t(k.value());
- char buf[255];
- if (! strftime(buf, 254, "%c", gmtime(&t)))
- buf[0] = '\0';
-
- cout << std::setw(30) << (indent + k.human_name() + ":") << " " << stringify(buf) << endl;
+ cout << std::setw(30) << (indent + k.human_name() + ":") << " "
+ << pretty_print_time(k.value()) << endl;
}
void visit(const MetadataSpecTreeKey<PlainTextSpecTree> & k)
diff --git a/src/output/console_query_task.cc b/src/output/console_query_task.cc
index bbbbc9d..1976d79 100644
--- a/src/output/console_query_task.cc
+++ b/src/output/console_query_task.cc
@@ -30,6 +30,7 @@
#include <paludis/util/sequence.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
#include <paludis/util/make_named_values.hh>
+#include <paludis/util/pretty_print.hh>
#include <paludis/package_dep_spec_properties.hh>
#include <paludis/mask.hh>
#include <paludis/metadata_key.hh>
@@ -648,22 +649,19 @@ namespace
if (0 == k.value())
return;
- time_t t(k.value());
- char buf[255];
- if (! strftime(buf, 254, "%c", gmtime(&t)))
- buf[0] = '\0';
+ std::string pretty_time(pretty_print_time(k.value()));
if (k.type() == type)
{
if (task->want_raw())
{
task->output_left_column(k.raw_name() + ":", in);
- task->output_right_column(stringify(buf));
+ task->output_right_column(pretty_time);
}
else
{
task->output_left_column(k.human_name() + ":", in);
- task->output_right_column(stringify(buf));
+ task->output_right_column(pretty_time);
}
}
}
diff --git a/src/output/mask_displayer.cc b/src/output/mask_displayer.cc
index 461768c..7732f27 100644
--- a/src/output/mask_displayer.cc
+++ b/src/output/mask_displayer.cc
@@ -25,6 +25,7 @@
#include <paludis/util/sequence.hh>
#include <paludis/util/set.hh>
#include <paludis/util/wrapped_forward_iterator.hh>
+#include <paludis/util/pretty_print.hh>
#include <paludis/name.hh>
#include <paludis/metadata_key.hh>
#include <sstream>
@@ -106,11 +107,7 @@ namespace
void visit(const MetadataTimeKey & k)
{
- time_t t(k.value());
- char buf[255];
- if (! strftime(buf, 254, "%c", gmtime(&t)))
- buf[0] = '\0';
- s << stringify(buf);
+ s << pretty_print_time(k.value());
}
void visit(const MetadataValueKey<std::tr1::shared_ptr<const Contents> > &)