From 66edfbbae6c6a37aeef2e933185863899c33d878 Mon Sep 17 00:00:00 2001 From: sk89q Date: Sun, 13 Mar 2011 20:36:28 -0700 Subject: [PATCH] Added /worldedit tz to set your timezone. It currently does not persist yet. Example: /we tz america/los_angeles --- .../worldedit/commands/WorldEditCommands.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/com/sk89q/worldedit/commands/WorldEditCommands.java b/src/com/sk89q/worldedit/commands/WorldEditCommands.java index 28b506f31..3a3c05803 100644 --- a/src/com/sk89q/worldedit/commands/WorldEditCommands.java +++ b/src/com/sk89q/worldedit/commands/WorldEditCommands.java @@ -19,6 +19,10 @@ package com.sk89q.worldedit.commands; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.Calendar; +import java.util.TimeZone; import com.sk89q.minecraft.util.commands.Command; import com.sk89q.minecraft.util.commands.CommandContext; import com.sk89q.minecraft.util.commands.CommandPermissions; @@ -29,6 +33,8 @@ import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEditException; public class WorldEditCommands { + private static DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z"); + @Command( aliases = {"version", "ver"}, usage = "", @@ -73,4 +79,21 @@ public class WorldEditCommands { session.setCUISupport(true); session.dispatchCUISetup(player); } + + @Command( + aliases = {"tz"}, + usage = "[timezone]", + desc = "Set your timezone", + min = 1, + max = 1 + ) + public static void tz(CommandContext args, WorldEdit we, + LocalSession session, LocalPlayer player, EditSession editSession) + throws WorldEditException { + TimeZone tz = TimeZone.getTimeZone(args.getString(0)); + session.setTimezone(tz); + player.print("Timezone set for this session to: " + tz.getDisplayName()); + player.print("The current time in that timezone is: " + + dateFormat.format(Calendar.getInstance(tz).getTime())); + } }