// -*- c++ -*- /* * Jakelib2 - General purpose C++ library * Copyright (C) 2001 Florian Wolff (florian@donuz.de) * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * * $Id: DateFormatSymbols.jlc,v 1.8 2003/09/27 08:10:28 florian Exp $ */ #include "jakelib2.h" #include "jakelib2/text/DateFormatSymbols.h" #include "jakelib2/text/DateFormat.h" #include "jakelib2/util/Calendar.h" using namespace jakelib::lang; using namespace jakelib::text; using namespace jakelib::util; JAKELIB_IMPLEMENT_CLASS("jakelib.text.DateFormatSymbols", DateFormatSymbols, Object); #pragma javasyntax /*****************************************************************************\ * DateFormatSymbols | *****************************************************************************/ DateFormatSymbols::DateFormatSymbols(Locale * loc) { init(loc); } DateFormatSymbols::DateFormatSymbols() { Locale *loc = Locale::getDefault(); init(loc); } /*****************************************************************************\ * init | *****************************************************************************/ void DateFormatSymbols::init(Locale * loc) { String *language = loc->getLanguage(); String *country = loc->getCountry(); setAmPmStrings("AM", "PM"); if (language->equals("de")) { setMonths("Januar", "Februar", "M\u00e4rz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"); setShortMonths("Jan", "Feb", "M\u00e4r", "Apr", "Mai", "Jun", "Jul", "Aug", "Sep", "Okt", "Nov", "Dez"); setWeekdays("Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"); setShortWeekdays("So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"); setDateTimeFormats("EEEE, d. MMMM yyyy HH.mm 'Uhr'", "d. MMMM yyyy HH:mm:ss", "dd.MM.yyyy HH:mm:ss", "dd.MM.yy HH:mm"); } else if (language->equals("fr")) { setMonths("Janvier", "F\u00e9vrier", "Mars", "Avril", "Mai", "Juin", "Juillet", "Ao\u00fbt", "Septembre", "Octobre", "Novembre", "D\u00e9cembre"); setShortMonths("Jan", "F\u00e9v", "Mar", "Avr", "Mai", "Jui", "Jui", "Ao\u00fb", "Sep", "Oct", "Nov", "D\u00e9c"); setWeekdays("Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"); setShortWeekdays("Dim", "Lun", "Mar", "Mer", "Jeu", "Ven", "Sam"); setDateTimeFormats("EEEE d MMMM yyyy HH 'h' mm", "d MMMM yyyy HH:mm:ss", "d MMM. yyyy HH:mm:ss", "d/MM/yy HH:mm"); } else if (language->equals("es")) { setMonths("Enero", "Febrero", "Marzo", "Abril", "Mayo", "Junio", "Julio", "Agosto", "Septiembre", "Octubre", "Noviembre", "Diciembre"); setShortMonths("Ene", "Feb", "Mar", "Abr", "May", "Jun", "Jul", "Ago", "Sep", "Oct", "Nov", "Dic"); setWeekdays("Domingo", "Lunes", "Martes", "Mi\u00E9rcoles", "Jueves", "Viernes", "S\u00E1bado"); setShortWeekdays("Dom", "Lun", "Mar", "Mi\u00E9", "Jue", "Vie", "S\u00E1b"); setDateTimeFormats("EEEE d 'de' MMMM 'de' yyyy HH'H'mm''", "d 'de' MMMM 'de' yyyy HH:mm:ss", "d-MMM-yyyy HH:mm:ss", "d/MM/yy HH:mm"); } else { setMonths("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "Decemeber"); setShortMonths("Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"); setWeekdays("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); setShortWeekdays("Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"); setDateTimeFormats("EEEE, MMMM d, yyyy H:mm:ss a", "MMMM d, yyyy H:mm:ss a", "MMM d, yyyy H:mm:ss a", "M/dd/yy HH:mm a"); if ("GB"->equals(country)) { setDateTimeFormats("d MMMM yyyy H:mm:ss 'o''clock'", "d MMMM yyyy H:mm:ss", "d-MMM-yyyy H:mm:ss", "d/MM/yy HH:mm"); } } } /*****************************************************************************\ * setMonths | *****************************************************************************/ void DateFormatSymbols::setMonths(String* m0, String* m1, String* m2, String* m3, String* m4, String* m5, String* m6, String* m7, String* m8, String* m9, String* m10, String* m11) { monthNames = new Strings(12); monthNames->set(0, m0); monthNames->set(1, m1); monthNames->set(2, m2); monthNames->set(3, m3); monthNames->set(4, m4); monthNames->set(5, m5); monthNames->set(6, m6); monthNames->set(7, m7); monthNames->set(8, m8); monthNames->set(9, m9); monthNames->set(10, m10); monthNames->set(11, m11); } /*****************************************************************************\ * setWeekdays | *****************************************************************************/ void DateFormatSymbols::setWeekdays(String* d1, String* d2, String* d3, String* d4, String* d5, String* d6, String* d7) { weekdays = new Strings(8); weekdays->set(0, null); weekdays->set(1, d1); weekdays->set(2, d2); weekdays->set(3, d3); weekdays->set(4, d4); weekdays->set(5, d5); weekdays->set(6, d6); weekdays->set(7, d7); } /*****************************************************************************\ * setShortMonths | *****************************************************************************/ void DateFormatSymbols::setShortMonths(String* m0, String* m1, String* m2, String* m3, String* m4, String* m5, String* m6, String* m7, String* m8, String* m9, String* m10, String* m11) { shortMonthNames = new Strings(12); shortMonthNames->set(0, m0); shortMonthNames->set(1, m1); shortMonthNames->set(2, m2); shortMonthNames->set(3, m3); shortMonthNames->set(4, m4); shortMonthNames->set(5, m5); shortMonthNames->set(6, m6); shortMonthNames->set(7, m7); shortMonthNames->set(8, m8); shortMonthNames->set(9, m9); shortMonthNames->set(10, m10); shortMonthNames->set(11, m11); } /*****************************************************************************\ * setShortWeekdays | *****************************************************************************/ void DateFormatSymbols::setShortWeekdays(String* d1, String* d2, String* d3, String* d4, String* d5, String* d6, String* d7) { shortWeekdays = new Strings(8); shortWeekdays->set(0, null); shortWeekdays->set(1, d1); shortWeekdays->set(2, d2); shortWeekdays->set(3, d3); shortWeekdays->set(4, d4); shortWeekdays->set(5, d5); shortWeekdays->set(6, d6); shortWeekdays->set(7, d7); } /*****************************************************************************\ * setDateTimeFormats | *****************************************************************************/ void DateFormatSymbols::setDateTimeFormats(String *full, String *l, String *m, String *s) { dateTimeFormats = new Strings(4); dateTimeFormats->set(DateFormat::FULL, full); dateTimeFormats->set(DateFormat::LONG, l); dateTimeFormats->set(DateFormat::MEDIUM, m); dateTimeFormats->set(DateFormat::SHORT, s); } /*****************************************************************************\ * setAmPmStrings | *****************************************************************************/ void DateFormatSymbols::setAmPmStrings(String *am, String *pm) { amPmStrings = new Strings(2); amPmStrings->set(Calendar::AM, am); amPmStrings->set(Calendar::PM, pm); } /*****************************************************************************\ * equals | *****************************************************************************/ jboolean DateFormatSymbols::equals(Object * obj) { if (!(obj->instanceOf("jakelib.text.DateFormatSymbols"))) return false; DateFormatSymbols *dfs = (DateFormatSymbols *) obj; return true; } /*****************************************************************************\ * getMonths | *****************************************************************************/ Strings* DateFormatSymbols::getMonths() { return monthNames; } /*****************************************************************************\ * getWeekdays | *****************************************************************************/ Strings* DateFormatSymbols::getWeekdays() { return weekdays; } /*****************************************************************************\ * getShortMonths | *****************************************************************************/ Strings* DateFormatSymbols::getShortMonths() { return shortMonthNames; } /*****************************************************************************\ * getShortWeekdays | *****************************************************************************/ Strings* DateFormatSymbols::getShortWeekdays() { return shortWeekdays; } /*****************************************************************************\ * getDateTimeFormats | *****************************************************************************/ Strings* DateFormatSymbols::getDateTimeFormats() { return dateTimeFormats; } /*****************************************************************************\ * getAmPmStrings | *****************************************************************************/ Strings* DateFormatSymbols::getAmPmStrings() { return amPmStrings; }