Skip to content

sc-date-time

This document is a user guide for the sc-date-time component version 6.5.63.

go-to-typical-definition

sc-date-time-field-Example-1-Image-4

1 Purpose

sc-date-time places a DateTimePicker control on a form, displaying as a text box with a calendar button. Clicking the calendar button will open a calendar pop-up allowing the user to select the date and time and have it display in the text box. If needed, the selected date and time can be edited either manually within the text box or by clicking the calendar button to select a different date and time from the calendar pop-up.

The system wide display format for sc-date-time values is defined in the Environment Configuration document by the "clientConfiguration", "dateFormat" field's "date and "time" values.

Example:

If the Environment Configuration document has the "clientConfiguration", "dateFormat" field defined as:

        "dateFormat": {
            "date": "dd/MM/yyyy",
            "general": "dd/MM/yyyy hh:mm a",
            "shortMonth": "dd/MMM/yyyy hh:mm a",
            "time": "hh:mm a"
        }

Then using the above "date" and "time" values, all sc-date-time values would display like:

!sc-date-time-field-Example-1-Image-4

Below is the full list of elements that can be used to build "date" and "time" display format strings:

  • 'yyyy': 4 digit representation of year (e.g. AD 1 => 0001, AD 2010 => 2010)
  • 'yy': 2 digit representation of year, padded (00-99). (e.g. AD 2001 => 01, AD 2010 => 10)
  • 'y': 1 digit representation of year, e.g. (AD 1 => 1, AD 199 => 199)
  • 'MMMM': Month in year (January-December)
  • 'MMM': Month in year (Jan-Dec)
  • 'MM': Month in year, padded (01-12)
  • 'M': Month in year (1-12)
  • 'LLLL': Stand-alone month in year (January-December)
  • 'dd': Day in month, padded (01-31)
  • 'd': Day in month (1-31)
  • 'EEEE': Day in Week, (Sunday-Saturday)
  • 'EEE': Day in Week, (Sun-Sat)
  • 'HH': Hour in day, padded (00-23)
  • 'H': Hour in day (0-23)
  • 'hh': Hour in AM/PM, padded (01-12)
  • 'h': Hour in AM/PM, (1-12)
  • 'mm': Minute in hour, padded (00-59)
  • 'm': Minute in hour (0-59)
  • 'ss': Second in minute, padded (00-59)
  • 's': Second in minute (0-59)
  • 'sss': Millisecond in second, padded (000-999)
  • 'a': AM/PM marker
  • 'Z': 4 digit (+sign) representation of the timezone offset (-1200-+1200)
  • 'ww': Week of year, padded (00-53). Week 01 is the week with the first Thursday of the year
  • 'w': Week of year (0-53). Week 1 is the week with the first Thursday of the year
  • 'G', 'GG', 'GGG': The abbreviated form of the era string (e.g. 'AD')
  • 'GGGG': The long form of the era string (e.g. 'Anno Domini')

Example:

If the Environment Configuration document has the "clientConfiguration", "dateFormat" field defined as:

        "dateFormat": {
            "date": "EEEE, MMMM d, y",
            "general": "dd/MM/yyyy hh:mm a",
            "shortMonth": "dd/MMM/yyyy hh:mm a",
            "time": "HH:mm a"
        },

Then using the above "date" and "time" values, all sc-date-time values would display like:

sc-date-time-display-format-2


The sc-date-time definition provides fields for setting the properties of a sc-date-time field and is fully described below.

 

2 Definition

sc-date-time is defined by a set of name/value pair fields consisting of:

  • Required system fields
  • Required customizable fields
  • Optional customizable fields

Note:

  1. Default values for fields described in the tables below are shown in bold text.

2.1 Required System Fields

Field Valid Values Description
componentName sc-date-time The component name.
Example:
"componentName": "sc-date-time"

2.2 Required Customizable Fields

Field Valid Values Description
name Any value written in camel case. Defines the name of the sc-date-time field in the document and database.
Example:
"name": "typicalDefnScDateTime"

2.3 Optional Customizable Fields

Field Valid Values Description
allowInput false Prevents the sc-date-time text box from being used to manually edit the date time value selected from the calendar pop-up.
Example:
"allowInput": false
true Allows the sc-date-time text box to be used to manually edit the date time value selected from the calendar pop-up.
defaultNow New Sets the sc-date-time value to the date and time the document was invoked.
Example:
"defaultNow": "New"
Save Sets the sc-date-time value to the date and time the document was last saved.
Example:
"defaultNow": "Save"
Defaults to no value.
disableSave true Changing the sc-date-time field value (i.e. selecting or editing a date time value) does not trigger the Save icon to flash.
Exiting the form without saving changes to the sc-date-time field value does not trigger a warning message to display.
In the Angular version of the sc-date-time component, clicking the Save icon will not save the sc-date-time field value to the document.
In the AngularJS version of the sc-date-time component, clicking the Save icon will save the sc-date-time field value to the document.

Example:
"disableSave": true
false Changing the sc-date-time field value (i.e. selecting or editing a date time value) does trigger the Save icon to flash.
Exiting the form without saving changes to the sc-date-time field value does trigger a warning message to display.
In both the Angular and AngularJS versions of the sc-date-time component, clicking the Save icon will save the sc-date-time field value to the document.
displayFormat date format string Display the date in the specified format
Notes:
  1. The date is still saved in ISO Date format.
  2. displayFormat only affects the output (display)
  3. Manual date and time entry still needs to be in the default format (defined in the environment configuration settings).
  4. Valid formats can be seen at https://flatpickr.js.org/formatting/

Example:
"displayFormat": "D d-m-y"

This example would display 5/11/2021 5:00PM as "Tue 05-11-21"

Example:
"displayFormat": "j M Y H:S"

This example would display 5/11/2021 5:00PM as "5th Nov 2021 17:00"
Defaults in accordance with the environment configuration settings.
See Section 1 Purpose for a description of how sc-date-time uses the Environment Configuration settings.
enabled false The sc-date-time field is greyed out.
A Stop icon appears on mouseover of the sc-date-time field.
A value cannot be set for the sc-date-time field.
Example:
"enabled": false
true Default value.
The sc-date-time field on the form is not greyed out.
A Stop icon does not appear on mouseover of the sc-date-time field.
A value can be set for the sc-date-time field.
fullWidth true The sc-date-time field displays full width on the form.
Example:
"fullWidth": true
false Default value.
The sc-date-time field does not display full width on the form.
label Any value Defines the name of the sc-date-time field on the form i.e. the field label.
Example:
"label": "Typical Defn sc-date-time"
Defaults to the sc-date-time field displays without a field label on the form.
mandatory true The sc-date-time field displays as mandatory (i.e. label in red text with an asterisk).
Saving without a value, a message prompts the user to enter a value for the sc-date-time field.
Example:
"mandatory": true
false Default value.
The field displays as optional (i.e. label in black text).
noCalendar true Hides the calendar portion of the calendar popup, allowing the user to select the time but not the date (the date is automatically set to the current date).
Example:
"noCalendar": true
false Default value.
Does not hide the calendar portion of the calendar popup, allowing the user to select both the date and time.
visible false The sc-date-time field is not visible on the form.
Example:
"visible": false
true Default value.
The sc-date-time field is visible on the form.

 

3 Typical Definition

Below is a typical sc-date-time definition, defined with its required fields plus any optional field whose value is typically other than its default value.

{
    "componentName": "sc-date-time",
    "name": "typicalDefnScDateTime",
    "label": "Typical Defn sc-date-time"
}

One or more of the optional fields shown below can be included in the above definition should a value other than their default value be required.

    "allowInput": false,
    "defaultNow": "New",
    "disableSave":true,
    "displayFormat": "D d-m-y",
    "enabled":false,
    "fullWidth":true,
    "mandatory": true,
    "noCalendar": true,
    "visible":false,

 

4 Examples

Example 1

sc-date-time defined with the typically needed fields.

{
    "componentName": "sc-date-time",
    "name": "typicalDefnScDateTime",
    "label": "Typical Defn sc-date-time"
}

Resulting field on the form:

sc-date-time-field-Example-1-Image-1

Clicking the calendar button will open the calendar pop-up allowing the user to select a date and time value.

Resulting field on the form after clicking the calendar button

sc-date-time-field-Example-1-Image-2


  • The calendar pop-up opens at the date with the current day circled. Buttons provide the ability display the calendar at a different month and year.

  • To select the current date and time, click the "Now" button. This closes the calendar pop-up and displays the current date and time in the sc-date-time text box.

  • To clear the sc-date-time field, click the "Clear" button.

  • To select a specific date and time, display the pop-up calendar at the required month and year and select the required day e.g. 4 Nov 2021. The selected day is highlighted and the calendar will show time editable fields initialized at the current time. Select the required time e.g. 9:35 PM:

    sc-date-time-field-Example-1-Image-3-Updated

    Click the "Done" button. This closes the calendar pop-up and displays the selected date and time in the sc-date-time text box.

Resulting field on the form after selecting the required date and time and closing the calendar pop-up

sc-date-time-field-Example-1-Image-4

Resulting field in the document and database:

"typicalDefnScDateTime": "2021-11-04T10:35:00.000Z"

Note: The date and time is saved in the document and database in ISO Date format.