Package ch.pollet.jzic.timezone

Examples of ch.pollet.jzic.timezone.Database


            System.out.println();
            System.out.println(jsap.getHelp());
            System.exit(0);
        }

        Database database = new Database();
        Parser parser     = new Parser(database);
        Compiler compiler = new Compiler(database);
        Writer writer = new Writer(database);

        parser.parse(config.getStringArray("inputFiles"));
View Full Code Here


        String line;
        Tokenizer t;
        Zone z;
        DateTime dt;
       
        Database db = new Database();
        ZoneParser zp = new ZoneParser(db);

        //-- Test 1
        line = "Zone1 1:34:08 - LMT 2000";
        t = new Tokenizer(line, "\t ", null, 0);
        zp.parse(t);

        dt = new DateTime();
        dt.setYear(2000);
        dt.setMonth(1);
        dt.setDay(1);
        dt.setHour(0);
        dt.setMinute(0);
        dt.setSecond(0);
        dt.setType(DateTime.Type.WALL);

        assertTrue(db.getZones().containsKey("Zone1"));
        z = db.getZones().get("Zone1").first();
        assertEquals(5648, z.getOffset());
        assertEquals(null, z.getRule());
        assertEquals("LMT", z.getFormat());
        assertEquals(dt, z.getUntil());

        //-- Test 2
        line = "Zone2 1:34:08 Rule LMT 2000 Feb 12 1u";
        t = new Tokenizer(line, "\t ", null, 0);
        zp.parse(t);

        dt = new DateTime();
        dt.setYear(2000);
        dt.setMonth(2);
        dt.setDay(12);
        dt.setHour(1);
        dt.setMinute(0);
        dt.setSecond(0);
        dt.setType(DateTime.Type.UTC);

        z = db.getZones().get("Zone2").first();
        assertEquals("Rule", z.getRule());
        assertEquals(dt, z.getUntil());

        //-- Test 3
        line = "Zone3 1:34:08 Rule LMT 2000 Mar 12 1:30s";
        t = new Tokenizer(line, "\t ", null, 0);
        zp.parse(t);

        dt = new DateTime();
        dt.setYear(2000);
        dt.setMonth(3);
        dt.setDay(12);
        dt.setHour(1);
        dt.setMinute(30);
        dt.setSecond(0);
        dt.setType(DateTime.Type.STD);

        z = db.getZones().get("Zone3").first();
        assertEquals(dt, z.getUntil());

        //-- Test 4
        line = "Zone4 1:34:08 Rule LMT 2000 Apr 12 1:30:44u";
        t = new Tokenizer(line, "\t ", null, 0);
        zp.parse(t);

        dt = new DateTime();
        dt.setYear(2000);
        dt.setMonth(4);
        dt.setDay(12);
        dt.setHour(1);
        dt.setMinute(30);
        dt.setSecond(44);
        dt.setType(DateTime.Type.UTC);

        z = db.getZones().get("Zone4").first();
        assertEquals(dt, z.getUntil());

        //-- Test 5
        line = "Zone5 -1:34:08 Rule LMT";
        t = new Tokenizer(line, "\t ", null, 0);
        zp.parse(t);

        dt = new DateTime();
        dt.setYear(Integer.MAX_VALUE);
        dt.setMonth(12);
        dt.setDay(31);
        dt.setHour(23);
        dt.setMinute(59);
        dt.setSecond(59);
        dt.setType(DateTime.Type.WALL);

        z = db.getZones().get("Zone5").first();
        assertEquals(dt, z.getUntil());
        assertEquals(-5648, z.getOffset());

        //-- Test 6
        line = "Zone6 0 Rule LMT 2009 Sep lastSun";
        t = new Tokenizer(line, "\t ", null, 0);
        zp.parse(t);

        dt = new DateTime();
        dt.setYear(2009);
        dt.setMonth(9);
        dt.setDay(27);
        dt.setHour(0);
        dt.setMinute(0);
        dt.setSecond(0);
        dt.setType(DateTime.Type.WALL);

        z = db.getZones().get("Zone6").first();
        assertEquals(dt, z.getUntil());

        //-- Test 7
        line = "Zone7 0 Rule LMT 2009 Oct Mon>=3";
        t = new Tokenizer(line, "\t ", null, 0);
        zp.parse(t);

        dt = new DateTime();
        dt.setYear(2009);
        dt.setMonth(10);
        dt.setDay(5);
        dt.setHour(0);
        dt.setMinute(0);
        dt.setSecond(0);
        dt.setType(DateTime.Type.WALL);

        z = db.getZones().get("Zone7").first();
        assertEquals(dt, z.getUntil());

        //-- Test 8
        line = "Zone8 0 Rule LMT 2009 Nov Mon>=5";
        t = new Tokenizer(line, "\t ", null, 0);
        zp.parse(t);

        dt = new DateTime();
        dt.setYear(2009);
        dt.setMonth(11);
        dt.setDay(9);
        dt.setHour(0);
        dt.setMinute(0);
        dt.setSecond(0);
        dt.setType(DateTime.Type.WALL);

        z = db.getZones().get("Zone8").first();
        assertEquals(dt, z.getUntil());

        //-- Test 9
        line = "Zone9 0 Rule LMT 2009 Dec Mon<=8";
        t = new Tokenizer(line, "\t ", null, 0);
        zp.parse(t);

        dt = new DateTime();
        dt.setYear(2009);
        dt.setMonth(12);
        dt.setDay(7);
        dt.setHour(0);
        dt.setMinute(0);
        dt.setSecond(0);
        dt.setType(DateTime.Type.WALL);

        z = db.getZones().get("Zone9").first();
        assertEquals(dt, z.getUntil());

        //-- Test 10
        line = "Zone10 0 Rule LMT 2009 Dec Mon<=14";
        t = new Tokenizer(line, "\t ", null, 0);
        zp.parse(t);

        dt = new DateTime();
        dt.setYear(2009);
        dt.setMonth(12);
        dt.setDay(14);
        dt.setHour(0);
        dt.setMinute(0);
        dt.setSecond(0);
        dt.setType(DateTime.Type.WALL);

        z = db.getZones().get("Zone10").first();
        assertEquals(dt, z.getUntil());
    }
View Full Code Here

public class DatabaseTest {
    Database db;
   
    @Before
    public void setUp() {
        db = new Database();
    }
View Full Code Here

        String line;
        Tokenizer t;
        Rule r;
        DateTime dt;

        Database db = new Database();
        RuleParser rp = new RuleParser(db);

        //-- Test 1
        line = "Rule1 2009 2010 - Sep lastSun 2:00w 1:30 -";
        t = new Tokenizer(line, "\t ", null, 0);
        rp.parse(t);

        dt = new DateTime();
        dt.setYear(2009);
        dt.setMonth(9);
        dt.setDay(27);
        dt.setHour(2);
        dt.setMinute(0);
        dt.setSecond(0);
        dt.setType(DateTime.Type.WALL);

        assertTrue(db.getRules().containsKey("Rule1"));
        assertEquals(1, db.getRules().get("Rule1").size());
        r = db.getRules().get("Rule1").get(0);
        assertEquals(2009, r.getFromYear());
        assertEquals(2010, r.getToYear());
        assertEquals(null, r.getType());
        r.getAt().setYear(2009);
        assertEquals(dt, r.getAt());
        assertEquals(5400, r.getOffset());
        assertEquals("", r.getFormat());

        //-- Test 2
        line = "Rule2 2009 2010 - Sep 1 2:00w 1:30:30 S";
        t = new Tokenizer(line, "\t ", null, 0);
        rp.parse(t);

        dt = new DateTime();
        dt.setYear(2009);
        dt.setMonth(9);
        dt.setDay(1);
        dt.setHour(2);
        dt.setMinute(0);
        dt.setSecond(0);
        dt.setType(DateTime.Type.WALL);

        assertTrue(db.getRules().containsKey("Rule2"));
        assertEquals(1, db.getRules().get("Rule2").size());
        r = db.getRules().get("Rule2").get(0);
        assertEquals(2009, r.getFromYear());
        assertEquals(2010, r.getToYear());
        assertEquals(null, r.getType());
        r.getAt().setYear(2009);
        assertEquals(dt, r.getAt());
View Full Code Here

TOP

Related Classes of ch.pollet.jzic.timezone.Database

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.