Libraries anvil time Calendar

class Calendar
extends anvil.lang.object
Calendar represents any time with millisecond precision.

Constructor
Calendar(int timestamp [, string timezone])
Calendar(int year, int month [, string timezone])
Calendar(int year, int month, int day [, string timezone])
Calendar(int year, int month, int day, int hour [, string timezone])
Calendar(int year, int month, int day, int hour, int minute [, string timezone])
Calendar(int year, int month, int day, int hour, int minute, int second [, string timezone])
Calendar(int tear, int month, int day, int hour, int minute, int second, int millisecond [, string timezone])
Creates instance of Calendar
Parameters timezone -  ID of timezone, as string


Methods

Calendar add(int field, int amount)
Calendar add(string field, int amount)
Moves time forward or backward given amount of time units. Unit depends on given field.

Calendar after(Calendar other)
Checks if current time is after the given time.

Calendar before(Calendar other)
Checks if current time is before the given time.

string format(string format)
See java.text.SimpleDateFormat.

int getFirstDayOfWeek()
Gets the first day of week.

int getLastDayOfWeek()
Gets the last day of week.

int getTime()
Returns the timestamp for this time. Timestamp is milliseconds since 1.1.1970 00:00.

boolean onSameDay(Calendar other)
Checks if given time is on same day as this.

string pack()
string pack(int level)
Packs the time into compact string representation.
Parameters level -  Level of detail, between 1 and 6: 1 for year, 2 for month, 3 for day of month, 4 for hour, 5 minute, 6 seconds.

Calendar roll(int field, int amount)
Calendar roll(string field, int amount)
Calendar roll(int field, boolean up)
Calendar roll(string field, boolean up)
Rolls specified field up or down a single unit, or given amount. When rolling another fields are not affected unless they resulting time would be non-existents (such as February 31).
Parameters up -  true for up, false for down
amount -  Amount of adjustment for given field, negative value rolls down.

Calendar set(int fieldId, int setting)
Calendar set(string fieldId, int setting)
Calendar set(int year, int month, int day)
Calendar set(int year, int month, int day)
Calendar set(int year, int month, int day, int hour, int minute)
Calendar set(int year, int month, int day, int hour, int minute, int second)
Sets the time.

Calendar setFirstDayOfWeek(int firstDayOfWeek)
Sets the first day of week.

Calendar setTime(int timestamp)
Sets this time by using timestamp. Timestamp is milliseconds since 1.1.1970 00:00.

Calendar unpack(string packedTime)
Unpacks packed time and sets this calendar to reflect that time.