From 04b65fbf95ae0567dfcb81882f01f81b6cad02c2 Mon Sep 17 00:00:00 2001 From: Vishesh Handa <me@vhanda.in> Date: Tue, 15 Jan 2019 14:37:13 +0100 Subject: [PATCH] Filename: Use iso8601 string This sucks balls. Overall, the datetime handling in Dart is really really bad. It just has the concept of local time or utc time. There are a few packages which attempt to solve this, but none which really solve it in the way I would like. All I want is someway to generate an iso8601 string with the timezone. And that my DateTime should be aware of the timezone as an offset east of UTC. Is that really so hard? --- lib/state_container.dart | 1 + lib/storage/git_storage.dart | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/state_container.dart b/lib/state_container.dart index 96fa6a07..8e515df9 100644 --- a/lib/state_container.dart +++ b/lib/state_container.dart @@ -49,6 +49,7 @@ class StateContainerState extends State<StateContainer> { getDirectory: getNotesDir, dirName: "journal", gitCloneUrl: "root@bcn.vhanda.in:git/test", + fileNameGenerator: (Note n) => n.created.toIso8601String(), ); StateContainerState(bool onBoardingCompleted) { diff --git a/lib/storage/git_storage.dart b/lib/storage/git_storage.dart index 597e64c2..c50aa006 100644 --- a/lib/storage/git_storage.dart +++ b/lib/storage/git_storage.dart @@ -24,9 +24,10 @@ class GitNoteRepository implements NoteRepository { @required this.gitCloneUrl, @required this.dirName, @required this.getDirectory, + @required fileNameGenerator, }) : _fileStorage = FileStorage( noteSerializer: new MarkdownYAMLSerializer(), - fileNameGenerator: (Note note) => note.id, + fileNameGenerator: fileNameGenerator, getDirectory: getDirectory, ) { // FIXME: This isn't correct. The gitUrl might not be cloned at this point!