Difference between revisions of "Date field"
|  (Redirected page to API:EPrints/MetaField/Date) |  (Added examples.  Improved other sections unhide ToC.) (Tag: Removed redirect) | ||
| Line 1: | Line 1: | ||
| − | + | {{fieldtypes}} | |
| − | |||
| − | |||
| == Inheritance == | == Inheritance == | ||
| − | |||
| * [[Metadata]] | * [[Metadata]] | ||
| ** [[Date field]] | ** [[Date field]] | ||
| == Description == | == Description == | ||
| + | This field is used to store a single date. Internally EPrints always uses ISO standard notation for dates, it avoids confusion. This is <tt>YYYY-MM-DD</tt>. | ||
| − | + | In bibliographies sometimes exact dates of publication (or other events) are not known. EPrints allows you to store month and year values in date fields. <tt>YYYY</tt> or <tt>YYYY-MM</tt>. | |
| − | + | In the database EPrints actually uses 3 integer fields to store the date, rather than a built in date field. This is because of the need to allow <tt>NULL</tt> in month and day if the date is just <tt>1998</tt>. | |
| − | |||
| − | In the database EPrints actually uses 3 integer fields to store the date, rather than a built in date field. This is because of the need to allow  | ||
| == Properties == | == Properties == | ||
| − | |||
| {| border="1" cellpadding="3" cellspacing="0" | {| border="1" cellpadding="3" cellspacing="0" | ||
| | name || default || description   | | name || default || description   | ||
| |- | |- | ||
| − | | '''min_resolution''' || day || One of day|month|year. If set to  | + | | '''min_resolution''' || day || One of day|month|year. If set to <tt>day</tt> then values of <tt>YYYY</tt> or <tt>YYYY-MM</tt> will cause a validation error. If set to <tt>month</tt> then values of <tt>YYYY</tt> will cause a validation error. If set to <tt>year</tt> then day, month or year resolutions are allowed. | 
| |- | |- | ||
| − | | '''render_res''' || day || One of day|month|year. If set to  | + | | '''render_res''' || day || One of <tt>day|month|year</tt>. If set to <tt>year</tt> then the dates <tt>1998-10-01</tt>, <tt>1998-10</tt> and <tt>1998</tt> would all be rendered as <tt>1998</tt>. This is not too useful in configuring the field, but can be set as a print option inside citation files. | 
| |- | |- | ||
| − | | '''render_style''' || long || One of short|long. If  | + | | '''render_style''' || long || One of <tt>short|long|dow</tt>. If <tt>long</tt> then you'll see <tt>8 September 1998</tt>. If <tt>short</tt> then <tt>08 Sep 1998</tt>.  <tt>dow</tt> would render <tt>Tuesday 8 September 1998</tt>. | 
| |} | |} | ||
| − | |||
| == Required Phrases == | == Required Phrases == | ||
| − | + | No additional phrases. | |
| − | |||
| == Database == | == Database == | ||
| − | |||
| Date fields are stored in the database as: | Date fields are stored in the database as: | ||
| Line 43: | Line 35: | ||
| == API == | == API == | ||
| + | See [[API:EPrints/MetaField/Date|API page]]. | ||
| Date values are represented in the API as scalars containing ISO encoded dates. eg. | Date values are represented in the API as scalars containing ISO encoded dates. eg. | ||
| Line 50: | Line 43: | ||
|   "1976-02-02" |   "1976-02-02" | ||
| − | == Searching == | + | === Searching === | 
| + | Date fields can be searched as either single values or ranges. Searching for "2006" will also match 2006-12-25. You can search for "2000-" to search dates in or after 2000. Or "2000-12-2003-01" for December 2000 through January 2003. | ||
| − | + | == Examples == | |
| + | Most basic example. | ||
| + |  { | ||
| + |      name => 'acceptance_date', | ||
| + |      type => 'date', | ||
| + |  } | ||
| + | Set minimum resolution to which the date must be specified is at least a <tt>month</tt>. | ||
| + |  { | ||
| + |      name => 'moratorium_date', | ||
| + |      type => 'date', | ||
| + |      min_resolution => 'month', | ||
| + |  } | ||
| + | Set resolution to render to the <tt>month</tt>, set rendering style to <tt>short</tt> (e.g. Feb 2023). | ||
| + |  { | ||
| + |     name => 'publication_date',  | ||
| + |     type => 'date',  | ||
| + |     render_res => 'month',  | ||
| + |     render_style => short', | ||
| + |  } | ||
Revision as of 16:04, 20 March 2023
EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects
Metadata Fields: Arclanguage - Base64 - Bigint - Boolean - Compound - Counter - Dataobjref - Date - Decimal - Email - Fields - Float - Id - Idci - Image - Int - Itemref - Keywords - Langid - Longtext - Longtext_counter - Multilang - Multipart - Name - Namedset - Pagerange - Recaptcha - Recaptcha3 - Relation - Search - Secret - Set - Storable - Subject - Subobject - Text - Time - Timestamp - Url - Uuid
Contents
Inheritance
Description
This field is used to store a single date. Internally EPrints always uses ISO standard notation for dates, it avoids confusion. This is YYYY-MM-DD.
In bibliographies sometimes exact dates of publication (or other events) are not known. EPrints allows you to store month and year values in date fields. YYYY or YYYY-MM.
In the database EPrints actually uses 3 integer fields to store the date, rather than a built in date field. This is because of the need to allow NULL in month and day if the date is just 1998.
Properties
| name | default | description | 
| min_resolution | day | month|year. If set to day then values of YYYY or YYYY-MM will cause a validation error. If set to month then values of YYYY will cause a validation error. If set to year then day, month or year resolutions are allowed. | 
| render_res | day | month|year. If set to year then the dates 1998-10-01, 1998-10 and 1998 would all be rendered as 1998. This is not too useful in configuring the field, but can be set as a print option inside citation files. | 
| render_style | long | long|dow. If long then you'll see 8 September 1998. If short then 08 Sep 1998. dow would render Tuesday 8 September 1998. | 
Required Phrases
No additional phrases.
Database
Date fields are stored in the database as:
fieldname_year SMALLINT, fieldname_month SMALLINT, fieldname_day SMALLINT
If a date only has a year value then it would be stored as 1998,NULL,NULL
API
See API page.
Date values are represented in the API as scalars containing ISO encoded dates. eg.
"1976" "1976-02" "1976-02-02"
Searching
Date fields can be searched as either single values or ranges. Searching for "2006" will also match 2006-12-25. You can search for "2000-" to search dates in or after 2000. Or "2000-12-2003-01" for December 2000 through January 2003.
Examples
Most basic example.
{
    name => 'acceptance_date',
    type => 'date',
}
Set minimum resolution to which the date must be specified is at least a month.
{
    name => 'moratorium_date',
    type => 'date',
    min_resolution => 'month',
}
Set resolution to render to the month, set rendering style to short (e.g. Feb 2023).
{
   name => 'publication_date', 
   type => 'date', 
   render_res => 'month', 
   render_style => short',
}
