Date

The Date namespace contain functions related to parsing and formatting of Date objects.
Format
// Format data according to specified format
// YY = Year with two digits (e.g. 06 or 2016)
// YYYY = Year with four digits (e.g. 2016)
// M = Month with one digit if possible (e.g. 1 or 12)
// MM = Month with two digits (e.g. 01 or 12)
// D = Day with one digit if possible (e.g. 1 or 24)
// DD = Day with two digits (e.g. 01 or 24)
// W = Week number (e.g. 1 or 34) - ISO 8601
// h = Hours with one digit if possible (e.g. 1 or 14)
// hh = Hours with two digits (e.g. 01 or 14)
// m = Minutes with one digit if possible (e.g. 1 or 27)
// mm = Minutes with two digits (e.g. 01 or 27)
// s = Seconds with one digit if possible (e.g. 1 or 55)
// ss = Seconds with two digits (e.g. 01 or 55)

Fit.Date.Format(new Date(), "YYYY"); // Returns e.g. "2016"
Fit.Date.Format(new Date(), "W"); // Returns e.g. "41"
Fit.Date.Format(new Date(), "DD/MM/YYYY"); // Returns e.g. "27/08/2016"
Fit.Date.Format(new Date(), "hh:mm:ss"); // Returns e.g. "14:38:54"
Fit.Date.Format(new Date(), "DD/MM-YYYY - hh:mm"); // Returns e.g. "26/08-2016 - 20:34"


GetWeek
// Get week number as integer (ISO 8601)
Fit.Date.GetWeek(new Date()); // Returns e.g. 1 or 49


Parse
// Parse Date as text into Date instance.
// First argument is the date as text.
// Second argument is the format used to intepret the date as text.
// Notice that week numbers cannot be parsed.

Fit.Date.Parse("27/8-2016", "DD/MM-YYYY"); // Returns instance of Date
Fit.Date.Parse("2016-8-1 14:43:01", "YYYY-MM-DD hh:mm:ss"); // Returns instance of Date
Fit.UI is open source (LGPL) - download or fork it on GitHub - website powered by Sitemagic CMS