X-Git-Url: http://jaekl.net/gitweb/?p=frank.git;a=blobdiff_plain;f=prod%2Fnet%2Fjaekl%2Ffrank%2FSchedule.java;h=10616b23007608c5802fb4989ee61dbf8408295e;hp=c7fd70bfcd3a7b5ed991bdaf537b9bf762af6971;hb=60dc53edca9ae2bcd6703e02b26acd47ef3d61a8;hpb=24f097b0fe78fa44f99b9f6f2e51a8e689d86a4a diff --git a/prod/net/jaekl/frank/Schedule.java b/prod/net/jaekl/frank/Schedule.java index c7fd70b..10616b2 100644 --- a/prod/net/jaekl/frank/Schedule.java +++ b/prod/net/jaekl/frank/Schedule.java @@ -6,22 +6,33 @@ import java.text.MessageFormat; import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; +import java.util.TimeZone; import net.jaekl.frank.octranspo.Route; import net.jaekl.frank.octranspo.StopInfo; import net.jaekl.frank.octranspo.Trip; public class Schedule { - Locale m_locale; - FrankBundle m_bundle; DateFormat m_hourMinFmt; DateFormat m_hourMinSecFmt; + FrankBundle m_bundle; + Locale m_locale; + Style m_style; public Schedule(Locale locale) { m_locale = locale; + m_style = new Style(); m_bundle = FrankBundle.getInst(locale); m_hourMinFmt = new SimpleDateFormat("hh:mma", locale); m_hourMinSecFmt = new SimpleDateFormat("hh:mm:ssa", locale); + + // We always display times in Ottawa (local) time, because that's the only + // time that makes sense for a user who wants to know when to catch a bus. + // In the (unlikely?) event that our server is in a different timezone, + // we need to explicitly specify the time zone that we want to use. + TimeZone tz = TimeZone.getTimeZone("America/Toronto"); + m_hourMinFmt.setTimeZone(tz); + m_hourMinSecFmt.setTimeZone(tz); } String trans(String key) { @@ -31,17 +42,7 @@ public class Schedule { String mapUrl(double latitude, double longitude) { return "http://www.openstreetmap.org/?mlat=" + latitude + "&mlon=" + longitude + "&zoom=15"; } - - void writeStyle(PrintWriter pw) { - pw.println(""); - } - + // Countdown timer that updates time remaining until each bus is expected. void writeScript(PrintWriter pw, String remainArray, int remainCount) { String min = trans(FrankBundle.MINUTES); @@ -73,7 +74,7 @@ public class Schedule { pw.println(""); pw.println(""); pw.println("" + title + ""); - writeStyle(pw); + new Style().writeStyle(pw); pw.println(""); }