Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

tail.datetime

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tail.datetime

A light-weight, translat- and configurable Open Source DateTime Picker, written in pure vanilla JavaScript!

  • 0.3.4
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
112
decreased by-22.76%
Maintainers
1
Weekly downloads
 
Created
Source

tail.DateTime

npm npm Software License Author

The tail.DateTime script is a fork of the Pure JS Calendar, written by MrGuiseppe. It is specially designed for the new, yet unpublished, backend theme for the FoxCMS. The tail.DateTime script offers the following changes compared to the Pure JS Calendar:

  • A Time Picker (Hours, Minutes, Seconds)
  • A Month-Based browse view
  • A slightly different date/time output format
  • A slightly different HTML class/id layout
  • A different JS structure / implementation / constructur (Prototyping)
  • Key Listener for 'Escape' (Close) and 'Enter' (Use Today / First Day of the month)
  • Auto-Close on click outside of the calendar popup / input element
  • Instance Caching + Calendar Caching with the first day in the week
  • Default value depending on the input field
  • "Translatable" Strings through the global variable
  • And many more... Check out the Changelog for details.

Demonstration

Work in Progress

The script is still Work in Progress and hasn't been tested much!

Thanks to MrGuiseppe and to Octicons for the Vector Graphics.

Options

    tail.DateTime(document.getElementById("my-input-field"), {
        static:         null,
        position:       "bottom",
        classNames:     "",
        dateFormat:     "YYYY-mm-dd",
        timeFormat:     "HH:ii:ss",
        dateRanges:     [],
        weekStart:      "SUN",
        startOpen:      false,
        stayOpen:       false,
        zeroSeconds:    false
    });

static

string
Pass an valid selector of an element where the Calendar Popup should be append to, leave it on null to use the absolute position calculation.

position

string
Sets the position of the DateTime popup field to "top", "left", "right" or "bottom". This option does not work if you pass an valid selector on static!

classNames

string or array
Adds custom class names to the main DateTime container element, pass and array or an space-separated list!

dateFormat

string or false
Pass an valid Date/Time Format (see below) or pass false to disable the Date picker.

timeFormat

string or false
Pass an valid Date/Time Format (see below) or pass false to disable the Time picker.

dateRanges

array
This option allows you to create one or more selectable periods of time. Each period defines itself through an array, where the first value if the start-point and the last one the end-point (which is also optional). You can use a Date object as value, a string as YYYY-MM-DD or the (translated) name of a weekday (See tailDateTime.strings.shorts).

Example:

The following Example limits the selectable area to:

  • From 2018-10-12 up to 2018-10-26
  • From 2018-11-04 up to 2018-11-30
  • From 2018-12-01 up to 2018-12-31
  • In all cases only from Monday up to Friday (Sunday and Saturday are not selectable)

The last array ["MON", "FRI"] limits only all selections before! If you want to just use a selection between Monday and Friday in general, add a third parameters with true.

tail.DateTime("#datetime", {
    dateRanges: [
        [new Date(2018, 9, 12), new Date(2018, 9, 26)],
        ["2018-11-4", "2018-11-30"],
        [new Date(2018, 11, 1), new Date(2018, 11, 31)],
        ["MON", "FRI"]
    ]
});

weekStart

string
Pass the (translated) string of the global variable tailDateTime.strings.shorts to change the shown first day in the week. (If no translation has been made, you can choose between: "SUN", "MON", "TUE", "WED", "THU", "FRI" and "SAT")

startOpen

boolean
Use true to show the DateTime Picker directly after the initialization.

stayOpen

boolean
Use true to keep the DateTime Picker open, even if an selection has been made or any other closing event has been triggered! (You can still close the DateTime Picker with the close() method!)

zeroSeconds

boolean
Use true to set the seconds to 00. This would be happen once, during the initialization.

Date/Time Format

CodeDescription
H24-hour format of an hour, use `HH` for leading zeros!
G12-hour format of an hour, use `GG` for leading zeros!
AUppercase Ante meridiem and Post meridiem (AM or PM).
aLowercase Ante meridiem and Post meridiem (am or om).
iMinutes, use `ii` for leading zeros.
sSeconds, use `ss` for leading zeros.
YA (4-digit) numeric representation of a year, used as `YY` or `YYYY`.
yA (2-digit) numeric representation of a year, used as `yy`.
mNumeric representation of a month, use `mm` for leading zeros.
MA short textual representation of a month, three letters.
FA full textual representation of a month, such as March.
dDay of the month, use `dd` for leading zeros.
DA textual representation of a day, three letters.
l(Lower `L`) A full textual representation of the day of the week.

Methods

    var calendar = tail.DateTime(document.getElementById("my-input-field"));
    calendar.<method>();

on(event, callback)

This method hooks an event with an respective callback function to the DateTime object. Available Events:

  • tail.DateTime::open, when the DateTime Picker opens.
  • tail.DateTime::close, when the DateTime Picker closes.
  • tail.DateTime::select, the a selection has been made.

open()

This method opens the calendar popup, if it isn't already open!

close()

This method closes the calendar popup, if it is still open!

toggle()

This method toggles the open/close option of the calendar popup.

remove()

This method removes the DateTime Picker elments and destroys the tail.DateTime picker instance.

switchMonth(monthNum, year)

This method changes the shown month (monthNum starts with 0). You can also use "prev" or "next" to just browse forward and back.

switchYear(year)

This method changes the year within the month view. You can also use "prev" or "next" to just browse forward and back.

selectDate(Y, M, D, H, i, s)

Select a date with year, month, day, hours, minutes and seconds.

selectTime(H, i, s)

Select a time (alias for selectDate) with hours, minutes and seconds.

Keywords

FAQs

Package last updated on 27 Sep 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc