Skip to content

Commit 9d89945

Browse files
committed
SkriptDate/Time - add setter for formats
- this way we can change this via config
1 parent fdb23ed commit 9d89945

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/main/java/io/github/syst3ms/skriptparser/util/SkriptDate.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
import java.util.TimeZone;
1313

1414
public class SkriptDate implements Comparable<SkriptDate> {
15-
// TODO make a config for this
16-
public final static String DATE_FORMAT = "EEEE dd MMMM yyyy HH:mm:ss.SSS"; // Add 'zzzXXX' to display time zone as well
15+
public static String DATE_FORMAT = "EEEE dd MMMM yyyy HH:mm:ss.SSS"; // Add 'zzzXXX' to display time zone as well
1716
public final static Locale DATE_LOCALE = Locale.US;
1817

1918
private static final TimeZone defaultTimeZone = TimeZone.getDefault();
@@ -93,6 +92,10 @@ public static TimeZone getDefaultTimeZone() {
9392
return defaultTimeZone;
9493
}
9594

95+
public static void setDefaultDateFormat(String format) {
96+
DATE_FORMAT = format;
97+
}
98+
9699
/**
97100
* @return the amount of milliseconds that have passed
98101
* since midnight, January 1st, 1970 in the UTC time zone

src/main/java/io/github/syst3ms/skriptparser/util/Time.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@
1515
* @author Mwexim
1616
*/
1717
public class Time implements Comparable<Time> {
18-
// TODO make a config for this
19-
public final static String TIME_FORMAT = "HH:mm:ss.SSS";
18+
public static String TIME_FORMAT = "HH:mm:ss.SSS";
2019
public final static Locale TIME_LOCALE = Locale.US;
2120

2221
/**
@@ -85,6 +84,10 @@ public static Time of(SkriptDate date) {
8584
return new Time(lcd.toLocalTime());
8685
}
8786

87+
public static void setDefaultTimeFormat(String format) {
88+
TIME_FORMAT = format;
89+
}
90+
8891
/**
8992
* Parses a given string as a time, using one of the three patterns.
9093
*

0 commit comments

Comments
 (0)