• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

CLI interface to medialist (fossil mirror)


Commit MetaInfo

Revision85e9274d4ae6cd7d5a839cf647cdf96860777643 (tree)
Zeit2021-09-21 19:28:36
Autormio <stigma@disr...>
Commitermio

Log Message

Simplify date formats in add.d and update.d

FossilOrigin-Name: 75e01670133063769c149d4be4c1e79374bc8d46c528e3619acf04fff67266f9

Ändern Zusammenfassung

Diff

--- a/add.d
+++ b/add.d
@@ -40,7 +40,6 @@ private enum NUMBER_OF_HEADERS = 6;
4040 import std.file : exists, isFile;
4141 import std.path : buildPath;
4242 import std.stdio : File, stderr, writefln;
43- import std.datetime.systime : Clock;
4443 import std.string : strip, split, toLower;
4544 import std.typecons : tuple, Tuple;
4645
@@ -167,13 +166,14 @@ private enum NUMBER_OF_HEADERS = 6;
167166 }
168167
169168 import std.array : replicate;
170- import std.format : format;
169+ import std.datetime.date : Date;
170+ import std.datetime.systime : Clock;
171171
172172 size_t previous_indent = 0;
173173
174- immutable currentTime = Clock.currTime();
175- immutable currentTimeString = format("%d-%d-%d", currentTime.year,
176- currentTime.month, currentTime.day);
174+ immutable currentDT = Clock.currTime();
175+ immutable currentDateString = Date(currentDT.year, currentDT.month,
176+ currentDT.day).toISOExtString();
177177
178178 foreach (header_pair; header_positions)
179179 {
@@ -197,14 +197,14 @@ private enum NUMBER_OF_HEADERS = 6;
197197 break;
198198 case "start_date":
199199 if (status.toLower == "watching" || status.toLower == "reading")
200- f.write(currentTimeString);
200+ f.write(currentDateString);
201201 break;
202202 case "end_date":
203203 if (status.toLower == "complete")
204- f.write(currentTimeString);
204+ f.write(currentDateString);
205205 break;
206206 case "last_updated":
207- f.write(currentTimeString);
207+ f.write(currentDateString);
208208 break;
209209 default:
210210 // should be impossible, unless D changes the default for string.
--- a/update.d
+++ b/update.d
@@ -36,6 +36,8 @@ import std.typecons : Tuple;
3636 handle_update(string program_name, string[] args, string data_dir)
3737 {
3838 import std.conv : ConvException, parse;
39+ import std.datetime.date : Date;
40+ import std.datetime.systime : Clock;
3941 import std.file : exists, isFile, readText;
4042 import std.format : format;
4143 import std.path : buildPath;
@@ -47,6 +49,9 @@ handle_update(string program_name, string[] args, string data_dir)
4749 string title = "";
4850 string status = "";
4951 string progress = "";
52+ auto currentDateTime = Clock.currTime();
53+ Date currentDate = Date(currentDateTime.year, currentDateTime.month,
54+ currentDateTime.day);
5055
5156 if (args[0] == "-h" || args[0] == "--help") {
5257 display_usage(program_name);
@@ -139,12 +144,8 @@ handle_update(string program_name, string[] args, string data_dir)
139144 string oldStatus = "";
140145
141146 import std.array : replicate;
142- import std.datetime.systime : Clock;
143- import std.format : format;
144-
145- immutable currentTime = Clock.currTime();
146- immutable currentTimeString = format("%d-%d-%d", currentTime.year,
147- currentTime.month, currentTime.day);
147+
148+ string currentDateString = currentDate.toISOExtString();
148149
149150 foreach (sectionIndent, section; sections)
150151 {
@@ -171,13 +172,13 @@ handle_update(string program_name, string[] args, string data_dir)
171172 updatedLine ~= progress;
172173 break;
173174 case MLHeaders.lastUpdated:
174- updatedLine ~= currentTimeString;
175+ updatedLine ~= currentDateString;
175176 break;
176177 case MLHeaders.startDate:
177178 if ((oldStatus == "plan-to-read" || oldStatus == "plan-to-watch")
178179 && (status.toLower == "reading" || status.toLower == "watching"))
179180 {
180- updatedLine ~= currentTimeString;
181+ updatedLine ~= currentDateString;
181182 }
182183 else
183184 {
@@ -189,7 +190,7 @@ handle_update(string program_name, string[] args, string data_dir)
189190 if ((oldStatus == "reading" || oldStatus == "watching")
190191 && (status.toLower == "complete"))
191192 {
192- updatedLine ~= currentTimeString;
193+ updatedLine ~= currentDateString;
193194 }
194195 else
195196 {