Package org.haystack.tagval

Examples of org.haystack.tagval.HDateTime


    // History
    //////////////////////////////////////////////////////////////////////////

    @Override
    protected void onHisRead(HDict entity, HDateTimeRange range, HGridWriter writer, HCol[] cols) {
        HDateTime ts = range.start;
        boolean isBool = ((HStr) entity.get("kind")).val.equals("Bool");
        int count = 0;
        HVal[] values = new HVal[2];
        HRow row = new HRow(null, values);
        while (ts.compareTo(range.end) <= 0) {
            HVal val = isBool ? (HVal) HBool.make(count % 2 == 0) : (HVal) HNum.make(count);
            if (ts != range.start) {
                values[0] = val;
                values[1] = ts;
                writer.writeRow(cols, row, count++);
            }
            ts = HDateTime.make(ts.millis() + 15 * 60 * 1000);
        }
        //System.out.println(count);
    }
View Full Code Here


        verify(HDateTime.make(2011, 1, 2, 3, 4, 5, utc, 0).compareTo(HDateTime.make(2011, 2, 2, 3, 4, 5, utc, 0)) < 0);
        verify(HDateTime.make(2011, 1, 2, 3, 4, 5, utc, 0).compareTo(HDateTime.make(2012, 1, 2, 3, 4, 5, utc, 0)) < 0);
        verify(HDateTime.make(2011, 1, 2, 3, 4, 5, utc, 0).compareTo(HDateTime.make(2011, 1, 2, 3, 4, 0, utc, 0)) > 0);

        // encoding
        HDateTime ts = HDateTime.make(1307377618069L, HTimeZone.make("New_York"));
        verifyZinc(ts, "2011-06-06T12:26:58.069-04:00 New_York");
        verifyEq(ts.date.toString(), "2011-06-06");
        verifyEq(ts.time.toString(), "12:26:58.069");
        verifyEq(ts.tzOffset, -4 * 60 * 60);
        verifyEq(ts.tz.name, "New_York");
        verifyEq(ts.tz.java.getID(), "America/New_York");
        verifyEq(ts.millis(), 1307377618069L);

        // convert back to millis
        ts = HDateTime.make(ts.date, ts.time, ts.tz, ts.tzOffset);
        verifyEq(ts.millis(), 1307377618069L);

        // different timezones
        ts = HDateTime.make(949478640000L, HTimeZone.make("New_York"));
        verifyZinc(ts, "2000-02-02T03:04:00-05:00 New_York");
        ts = HDateTime.make(949478640000L, HTimeZone.make("UTC"));
View Full Code Here

        verifyMidnight(HDate.make(2011, 12, 15), "Chicago", "2011-12-15T00:00:00-06:00 Chicago");
        verifyMidnight(HDate.make(2008, 2, 29), "Phoenix", "2008-02-29T00:00:00-07:00 Phoenix");
    }

    private void verifyMidnight(HDate date, String tzName, String str) {
        HDateTime ts = date.midnight(HTimeZone.make(tzName));
        verifyEq(ts.date, date);
        verifyEq(ts.time.hour, 0);
        verifyEq(ts.time.min, 0);
        verifyEq(ts.time.sec, 0);
        verifyEq(ts.toString(), str);
        verifyEq(ts, read(ts.toZinc()));
        verifyEq(ts.millis(), ((HDateTime) read(str)).millis());
    }
View Full Code Here

        HTimeZone ny = HTimeZone.make("New_York");
        HDate today = HDate.today();
        HDate yesterday = today.minusDays(1);
        HDate x = HDate.make(2011, 7, 4);
        HDate y = HDate.make(2011, 11, 4);
        HDateTime xa = HDateTime.make(x, HTime.make(2, 30), ny);
        HDateTime xb = HDateTime.make(x, HTime.make(22, 5), ny);

        verifyRange(HDateTimeRange.make("today", ny), today, today);
        verifyRange(HDateTimeRange.make("yesterday", ny), yesterday, yesterday);
        verifyRange(HDateTimeRange.make("2011-07-04", ny), x, x);
        verifyRange(HDateTimeRange.make("2011-07-04,2011-11-04", ny), x, y);
        verifyRange(HDateTimeRange.make("" + xa + "," + xb, ny), xa, xb);

        HDateTimeRange r = HDateTimeRange.make(xb.toString(), ny);
        verifyEq(r.start, xb);
        verifyEq(r.end.date, today);
        verifyEq(r.end.tz, ny);
    }
View Full Code Here

        // create some items
        HDate date = HDate.make(2010, 6, 7);
        HTimeZone tz = HTimeZone.make(kw.getStr("tz"));
        HHisItem[] write = new HHisItem[5];
        for (int i = 0; i < write.length; ++i) {
            HDateTime ts = HDateTime.make(date, HTime.make(i + 1, 0), tz);
            HVal val = HNum.make(i, "kW");
            write[i] = HHisItem.make(ts, val);
        }

        // write and verify
View Full Code Here

TOP

Related Classes of org.haystack.tagval.HDateTime

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.