Skip to content

Commit fcc3cb3

Browse files
committed
feat: remove datetime
1 parent f44e326 commit fcc3cb3

File tree

2 files changed

+1
-53
lines changed

2 files changed

+1
-53
lines changed

test/inflator.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# inflator.toml syntax documentation: https://github.com/inflated-goboscript/inflator#inflator
2-
name = 'test'
2+
name = "test"
33
username = "inflated-goboscript"
44

55
[dependencies]

time.gs

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -3,55 +3,3 @@
33

44
%include inflator/time/src/get_time
55
%include inflator/time/src/get_timezone
6-
7-
# datetime
8-
9-
struct datetime {
10-
year = 1970,
11-
month = 1,
12-
day = 1,
13-
hour = 0,
14-
minute = 0,
15-
second = 0,
16-
microsecond = 0,
17-
tzh=0, # either timezone hour, or "null". If null, implies there is no timezone data attached.
18-
tzm=0 # timezone minute. If tzh is null, ignore tzm, so default is "00"
19-
}
20-
21-
%define DATETIME_NOW() datetime{ \
22-
year: current_year(), \
23-
month: current_month(), \
24-
day: current_date(), \
25-
hour: current_hour(), \
26-
minute: current_minute(), \
27-
second: current_second(), \
28-
microsecond: floor(CURRENT_MILLISECOND() * 1000), \
29-
tzh: TIMEZONE(),\
30-
tzm: 0}
31-
32-
func dt_str(datetime dt) {
33-
local suffix = "";
34-
if $dt.microsecond != 0 {
35-
# add microseconds if applicable
36-
# according to the Wikipedia page: There is no limit on the number of decimal places for the decimal fraction
37-
suffix &= "." & floor($dt.microsecond);
38-
}
39-
40-
if $dt.tzh != "null" {
41-
# add optional timezone data
42-
if $dt.tzh == 0 and $dt.tzm == 0 {
43-
# if it's UTC, just add a Z
44-
suffix &= "Z";
45-
} else {
46-
if $dt.tzh[1] != "-" {
47-
suffix &= "+";
48-
}
49-
50-
suffix &= zfill($dt.tzh, 2) & ":" & zfill($dt.tzm, 2);
51-
}
52-
}
53-
54-
return $dt.year & "-" & zfill($dt.month, 2) & "-" & zfill($dt.day, 2) &
55-
"T" & zfill($dt.hour, 2) & ":" & zfill($dt.minute, 2) & ":" & zfill($dt.second, 2) &
56-
suffix;
57-
}

0 commit comments

Comments
 (0)