Skip to content

Commit e68e3ce

Browse files
committed
month, unixTime (local and utc) options to TimeInfo
1 parent 8de3883 commit e68e3ce

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

Code/MethodSystem/Methods/TimeMethods/TimeInfoMethod.cs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,33 @@ public class TimeInfoMethod : LiteralValueReturningMethod
2323
"second",
2424
"minute",
2525
"hour",
26+
"month",
2627
"year",
2728
"dayOfWeek",
2829
new("dayOfWeekNumber", "Instead of returning e.g. 'Monday', will return 1"),
2930
"dayOfMonth",
30-
"dayOfYear")
31+
"dayOfYear",
32+
new("unixTimeUtc","Useful for making discord timestamps "),
33+
"unixTimeLocal")
3134
];
3235

3336
public override void Execute()
3437
{
35-
ReturnValue = Args.GetOption("options").ToLower() switch
38+
ReturnValue = Args.GetOption("options") switch
3639
{
3740
"second" => new NumberValue(DateTime.Now.Second),
3841
"minute" => new NumberValue(DateTime.Now.Minute),
3942
"hour" => new NumberValue(DateTime.Now.Hour),
43+
"month" => new NumberValue(DateTime.Now.Month),
4044
"year" => new NumberValue(DateTime.Now.Year),
4145
"dayofweek" => new StaticTextValue(DateTime.Now.DayOfWeek.ToString()),
4246
"dayofweeknumber" => (uint)DateTime.Now.DayOfWeek == 0
4347
? new NumberValue(7)
4448
: new NumberValue((uint)DateTime.Now.DayOfWeek),
4549
"dayofmonth" => new NumberValue(DateTime.Now.Day),
4650
"dayofyear" => new NumberValue(DateTime.Now.DayOfYear),
51+
"unixtimeutc" => new NumberValue(DateTimeOffset.UtcNow.ToUnixTimeSeconds()),
52+
"unixtimelocal" => new NumberValue(DateTimeOffset.Now.ToUnixTimeSeconds()),
4753
_ => throw new AndrzejFuckedUpException()
4854
};
4955
}

0 commit comments

Comments
 (0)