01: /*
02: * @(#)calendar.java 1.2 04/12/06
03: *
04: * Copyright (c) 1997-2004 Sun Microsystems, Inc. All Rights Reserved.
05: *
06: * See the file "LICENSE.txt" for information on usage and redistribution
07: * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
08: */
09: package org.pnuts.lib;
10:
11: import java.util.Calendar;
12: import pnuts.lang.Executable;
13: import pnuts.lang.Context;
14: import pnuts.lang.Package;
15:
16: public class calendar implements Executable {
17:
18: static String[] names0 = { "getYear", "getMonth", "getWeekOfYear",
19: "getDayOfYear", "getHour", "getMinute", "getSecond",
20: "getMillisecond", "getDayOfMonth", "getDayOfWeek" };
21:
22: static String[] names1 = { "addYear", "addMonth", "addWeek",
23: "addDay", "addHour", "addMinute", "addSecond",
24: "addMillisecond" };
25:
26: static String[] names2 = { "diffYear", "diffMonth", "diffWeek",
27: "diffDay", "diffHour", "diffMinute", "diffSecond",
28: "diffMillisecond" };
29:
30: static int[] elements = { Calendar.YEAR, Calendar.MONTH,
31: Calendar.WEEK_OF_YEAR, Calendar.DAY_OF_YEAR,
32: Calendar.HOUR_OF_DAY, Calendar.MINUTE, Calendar.SECOND,
33: Calendar.MILLISECOND, Calendar.DAY_OF_MONTH,
34: Calendar.DAY_OF_WEEK };
35:
36: public Object run(Context context) {
37: Package pkg = Package.getPackage("pnuts.lib", context);
38: for (int i = 0; i < names0.length; i++) {
39: String name = names0[i].intern();
40: pkg.set(name, new DateElement(elements[i], name), context);
41: pkg.export(name);
42: }
43: for (int i = 0; i < names1.length; i++) {
44: String name = names1[i].intern();
45: pkg.set(name, new DateElementAdd(elements[i], name),
46: context);
47: pkg.export(name);
48: }
49: for (int i = 0; i < names2.length; i++) {
50: String name = names2[i].intern();
51: pkg.set(name, new DateElementDiff(elements[i], name),
52: context);
53: pkg.export(name);
54: }
55: return null;
56: }
57: }
|