diff options
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Util.java | 10 | ||||
-rw-r--r-- | Essentials/src/messages.properties | 4 | ||||
-rw-r--r-- | Essentials/src/messages_de.properties | 4 |
3 files changed, 11 insertions, 7 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java index bcbed1064..ed1ea2d0b 100644 --- a/Essentials/src/com/earth2me/essentials/Util.java +++ b/Essentials/src/com/earth2me/essentials/Util.java @@ -102,7 +102,10 @@ public class Util fromDate.add(type, future ? -1 : 1); return diff; } - private static Pattern timePattern = Pattern.compile( + + public static long parseDateDiff(String time, boolean future) throws Exception + { + Pattern timePattern = Pattern.compile( "(?:([0-9]+)\\s*y[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?" @@ -110,9 +113,6 @@ public class Util + "(?:([0-9]+)\\s*h[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?" + "(?:([0-9]+)\\s*(?:s[a-z]*)?)?", Pattern.CASE_INSENSITIVE); - - public static long parseDateDiff(String time, boolean future) throws Exception - { Matcher m = timePattern.matcher(time); int years = 0; int months = 0; @@ -171,7 +171,7 @@ public class Util } if (!found) { - throw new Exception("Illegal date format."); + throw new Exception(Util.i18n("illegalDate")); } Calendar c = new GregorianCalendar(); if (years > 0) diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index ccbc8fa68..f460553f9 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -301,4 +301,6 @@ worth = \u00a77Stack of {0} worth \u00a7c{1}\u00a77 ({2} item(s) at {3} each) worthMeta = \u00a77Stack of {0} with metadata of {1} worth \u00a7c{2}\u00a77 ({3} item(s) at {4} each) onlyPlayers = Only in-game players can use {0}. unignorePlayer = You are not ignoring player {0} anymore. -ignorePlayer = You ignore player {0} from now on.
\ No newline at end of file +ignorePlayer = You ignore player {0} from now on. +illegalDate = Illegal date format. +timePattern = (?:([0-9]+)\\s*y[a-z]*[,\\s]*)?(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?(?:([0-9]+)\\s*d[a-z]*[,\\s]*)?(?:([0-9]+)\\s*h[a-z]*[,\\s]*)?(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?(?:([0-9]+)\\s*(?:s[a-z]*)?)?
\ No newline at end of file diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 276f9594d..016aa95e1 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -301,4 +301,6 @@ worth = \u00a77Stack of {0} worth \u00a7c{1}\u00a77 ({2} item(s) at {3} each) worthMeta = \u00a77Stack of {0} with metadata of {1} worth \u00a7c{2}\u00a77 ({3} item(s) at {4} each) onlyPlayers = Only in-game players can use {0}. unignorePlayer = You are not ignoring player {0} anymore. -ignorePlayer = You ignore player {0} from now on.
\ No newline at end of file +ignorePlayer = You ignore player {0} from now on. +illegalDate = Illegal date format. +timePattern = (?:([0-9]+)\\s*[yj][a-z]*[,\\s]*)?(?:([0-9]+)\\s*mo[a-z]*[,\\s]*)?(?:([0-9]+)\\s*w[a-z]*[,\\s]*)?(?:([0-9]+)\\s*[dt][a-z]*[,\\s]*)?(?:([0-9]+)\\s*(?:h|st)[a-z]*[,\\s]*)?(?:([0-9]+)\\s*m[a-z]*[,\\s]*)?(?:([0-9]+)\\s*(?:s[a-z]*)?)?
\ No newline at end of file |