Skip to content

Commit

Permalink
3.6.6 - Fix Import
Browse files Browse the repository at this point in the history
  • Loading branch information
Lains committed Dec 3, 2021
1 parent edd96f8 commit ae3e825
Showing 1 changed file with 20 additions and 15 deletions.
35 changes: 20 additions & 15 deletions src/Services/FileManager.vala
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
namespace Khronos.FileManager {

public async void save_logs (LogViewModel view_model) throws Error {
debug ("Save as button pressed.");
string tasks = "";
var file = yield Dialog.display_save_dialog ();
uint i, n = view_model.logs.get_n_items ();

tasks += "task,timedate\n";
tasks += "task,timedate,tags\n";
for (i = 0; i < n; i++) {
var item = view_model.logs.get_item (i);
tasks += "\"" + ((Log)item).name.replace("\"", "") +
"\",\"" + ((Log)item).timedate.replace("\"", "") + "\"\n";
"\",\"" + ((Log)item).timedate.replace("\"", "").replace("\n", "") +
"\",\"" + ((Log)item).tags + "\"\n";
}

GLib.FileUtils.set_contents (file.get_path(), tasks);
Expand All @@ -36,22 +36,27 @@ namespace Khronos.FileManager {
line = line.strip ();
if (line.has_prefix ("\"")) {
GLib.DateTime dt = new GLib.DateTime.now_local ();
string[] logged = line.replace ("\"", "").strip ().split(",");
print("%s\n".printf(logged[0]));
print("%s\n".printf(logged[1]));
string[] logged = line.replace ("\"", "").strip().split(",");

GLib.DateTime taskdt = new GLib.DateTime.local (dt.get_year (),
int.parse(logged[2].substring(1,2)),
int.parse(logged[2].substring(4,2)),
int.parse(logged[2].substring(7,2)),
int.parse(logged[2].substring(12,2)),
double.parse(logged[2].substring(17,2)));

current_log = new Log ();
current_log.name = logged[0];
current_log.timedate = "%s\n%s%s".printf(logged[1],
("%s").printf (dt.format ("%a, %d/%m %H%M%S")),
("%s").printf (dt.add_full (0,
0,
0,
((int)logged[1].substring(0,1)),
((int)logged[1].substring(3,4)),
((int)logged[1].substring(6,7))).format ("%H%M%S")));

current_log.timedate = "%s\n%s%s".printf(logged[1].substring(0,12),
("%s").printf (logged[1].substring(13,3) + ", " + logged[2].substring(0,20)),
("%s").printf (taskdt.add_full (dt.get_year (),
int.parse(logged[2].substring(1,2)),
int.parse(logged[2].substring(4,2)),
int.parse(logged[1].substring(1,2)),
int.parse(logged[1].substring(5,2)),
double.parse(logged[1].substring(10,2))).format ("%H%M%S")));

current_log.tags = logged[3];
logs.add (current_log);
}

Expand Down

0 comments on commit ae3e825

Please sign in to comment.