]> git.lyx.org Git - lyx.git/blobdiff - src/support/lyxtime.C
Fix several filename and environment variable encoding problems
[lyx.git] / src / support / lyxtime.C
index cbe6223bbb26b412a873c537a52e05f3319a922d..aabd1229dab1a7cbfb82b93d23d71342619f8f16 100644 (file)
@@ -11,6 +11,9 @@
 #include <config.h>
 
 #include "support/lyxtime.h"
+#include "lyxrc.h"
+
+using std::string;
 
 namespace lyx {
 
@@ -19,4 +22,19 @@ time_type current_time()
        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