Variables for Dates and Times

By Sandra Schloen, March 2021

OCHRE has several options for managing dates and times:

  • A variable of Type Date: a standard calendar date; e.g. an excavation date, or birthdate 1991-07-20

  • A variable of Type Date-Time: think of this as a timestamp; e.g. Sat Jul 20 06:12:00 CDT 1991

  • A variable of Type Time: this is strictly for time, no date; e.g. an audio clip cue at 06:12:18

Variable options

On the Project Preferences pane you can set the default date format for your project. This will be applied to values of Date properties and to the date components of values of Date-Time properties.

Variables of date and time types also allow you to specify a Format template (also known as a mask). This determines the format in which the values of the variable are entered and displayed. It is important to note that if a format mask is specified for a variable, the data value must be entered either in the format defined by the mask, or in the default format, or else it will be considered invalid. If no mask is specified, the data value must be entered in the default format. Default formats for these variable types are detailed below.

Note, too, that the variable-level format for a Date variable will override the project-level format when viewing dates, but that the date-chooser on the Properties pane for entering date Values will always use the project-level format and not the variable-level format. This ensures consistency in entering dates, although they may be displayed differently by different variables.

Additional Date options

A date-chooser is automatically available when entering dates as property values.

A date's value can be defaulted either to be the same as the last date entered (e.g. if you are doing a sequence of back-dated data entry), or it can default to the current date. If neither of these are set, the date will be blank to start.

Default format: yyyy-MM-dd
(corresponds to ISO Local Date standard)

Additional Date-Time options

A date-time value can be awkward to enter manually. No date-chooser is presented when editing a date-time property value. Since date-time properties typically represent a timestamp, chances are you will want to turn on the option to Default to right now.

Default format: yyyy-MM-ddTHH:mm:ss
(corresponds to ISO Local Date Time standard)

There are no additional options for Time variables (apart from the format mask). Note that one to nine digits can be specified (S), up to the nano-of-second, following a decimal point after the hours (HH), minutes (mm), and seconds (ss) are specified.

Default format: HH:mm:ss.SSS
(corresponds to ISO Local Time standard)

In the default format, SSS represents milliseconds, but OCHRE's (i.e. Java's) time data can be represented to the micro- (1.0E-6 ) or nano-second (1.0E-9).

See the examples of default and custom date, date-time, and time properties.

Date Formats

Format masks for controlling the display of date and time properties can use the following standard codes for representing the components of the date and time values. Here is a tutorial (not affiliated with OCHRE) where you can learn more about formatting date/time values.