From 0f5656e152a20a30a0728e33ed4371338ac734df Mon Sep 17 00:00:00 2001 From: otya128 Date: Sat, 24 Dec 2016 17:04:28 +0900 Subject: [PATCH] Implement TMREAD --- SMILEBASIC/builtinfunctions.d | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/SMILEBASIC/builtinfunctions.d b/SMILEBASIC/builtinfunctions.d index 05c65e8..a1c8970 100644 --- a/SMILEBASIC/builtinfunctions.d +++ b/SMILEBASIC/builtinfunctions.d @@ -758,6 +758,33 @@ class BuiltinFunction formattedRead(v, "%d/%d/%d", &Y, &M, &D); W = cast(int)DateTime(Y, M, D).dayOfWeek; } + static void TMREAD(out int H, out int M, out int S) + { + import std.datetime; + auto currentTime = Clock.currTime(); + H = currentTime.hour; + M = currentTime.minute; + S = currentTime.second; + } + static void TMREAD(wstring time, out int H, out int M, out int S) + { + import std.datetime; + import std.format; + try + { + formattedRead(time, "%d:%d:%d", &H, &M, &S); + } + catch + { + throw new IllegalFunctionCall("TMREAD", 1); + } + if (!time.empty) + { + throw new IllegalFunctionCall("TMREAD", 1); + } + if (H < 0 || M < 0 || S < 0 || H > 99 || M > 99 || S > 99) + throw new IllegalFunctionCall("TMREAD", 1); + } static int LEN(Value ary) { return ary.length;