+2005-07-05 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
+
+ * text3.C (doDispatch): rewrite LFUN_DATE_INSERT using the brandnew
+ formatted_time methods in support/lyxtime.
+
2005-07-04 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* toc.[Ch]: new method getGuiName, which is used by the frontends
+2005-07-05 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
+
+ * ControlChanges.C (getChangeDate): use localized date (from
+ support/lyxtime).
+
2005-07-04 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
* ControlToc.[Ch]: new method getGuiName, which is used by the frontends
#include "changes.h"
#include "funcrequest.h"
#include "lyxfind.h"
-#include "support/lstrings.h"
+#include "support/lyxtime.h"
using std::string;
namespace lyx {
-using support::rtrim;
-
namespace frontend {
if (c.type == Change::UNCHANGED || !c.changetime)
return string();
- // ctime adds newline; trim it off!
- string const date = rtrim(ctime(&c.changetime), "\n");
- return date;
+ return formatted_time(c.changetime);
}
+2005-07-05 Jürgen Spitzmüller <j.spitzmueller@gmx.de>
+
+ * lyxtime.[Ch]: two new functions formatted_time, which return
+ the strftime-formatted localized date/time.
+
2005-06-24 Georg Baum <Georg.Baum@post.rwth-aachen.de>
* FileName.C (mangledFilename): replace spaces with _
#include <config.h>
#include "support/lyxtime.h"
+#include "lyxrc.h"
+
+using std::string;
namespace lyx {
return time(0);
}
+
+string const formatted_time(time_type t, string const & fmt)
+{
+ struct tm * loc_tm = localtime(&t);
+ char date[50];
+ strftime(date, sizeof(date), fmt.c_str(), loc_tm);
+ return string(date);
+}
+
+
+string const formatted_time(time_type t)
+{
+ return formatted_time(t, lyxrc.date_insert_format);
+}
+
} // namespace lyx
* Licence details can be found in the file COPYING.
*
* \author John Levon
+ * \author Jürgen Spitzmüller
*
* Full author contact details are available in file CREDITS.
*/
#define LYXTIME_H
#include <time.h>
+#include <string>
+
namespace lyx {
time_type current_time();
+/** Returns a locale-dependent formatting of the date
+ * and time encoded in \c time. The \p fmt string
+ * holds the formatting arguments of \c strftime.
+ */
+std::string const formatted_time(time_type t, std::string const & fmt);
+
+/** Returns a locale-dependent formatting of the date
+ * and time encoded in \c time. For the formatting,
+ * \c lyxrc.date_insert_format is being used.
+ */
+std::string const formatted_time(time_type t);
+
}; // namespace lyx
#endif // LYXTIME_H
#include "support/lstrings.h"
#include "support/lyxlib.h"
#include "support/convert.h"
+#include "support/lyxtime.h"
#include "mathed/math_hullinset.h"
#include "mathed/math_macrotemplate.h"
break;
}
- case LFUN_DATE_INSERT: {
- lyx::cap::replaceSelection(cur);
- time_t now_time_t = time(NULL);
- struct tm * now_tm = localtime(&now_time_t);
- setlocale(LC_TIME, "");
- string arg;
- if (!cmd.argument.empty())
- arg = cmd.argument;
+ case LFUN_DATE_INSERT:
+ if (cmd.argument.empty())
+ bv->owner()->dispatch(FuncRequest(LFUN_SELFINSERT,
+ lyx::formatted_time(lyx::current_time())));
else
- arg = lyxrc.date_insert_format;
- char datetmp[32];
- int const datetmp_len =
- ::strftime(datetmp, 32, arg.c_str(), now_tm);
-
- for (int i = 0; i < datetmp_len; i++)
- insertChar(cur, datetmp[i]);
-
- cur.resetAnchor();
- moveCursor(cur, false);
+ bv->owner()->dispatch(FuncRequest(LFUN_SELFINSERT,
+ lyx::formatted_time(lyx::current_time(), cmd.argument)));
break;
- }
case LFUN_MOUSE_TRIPLE:
if (cmd.button() == mouse_button::button1) {