@writetome51/get-date-id-time-id
v2.0.0
Published
Functions that return the current date as string of digits and return the current time as string of digits.
Downloads
11
Maintainers
Readme
getDateID(options?): string
// `options`:
{
includeFullYear?: boolean, // default false
order?: 'ymd' | 'ydm' | 'myd' | 'mdy' | 'dym' | 'dmy', // default 'ymd'
separator?: string, // default '-'
separateEach?: boolean // default false
}
getTimeID(options?): string
// `options`:
{
order?: 'hms' | 'hsm' | 'msh' | 'mhs' | 'smh' | 'shm', // default 'hms'
separator?: string, // default '-'
separateEach?: boolean // default false
includeTimezoneOffset?: boolean // default true
}
getDefaultsFor_getTimeIDOptions(): Object
Returns default options for getTimeID()
.
getDefaultsFor_getDateIDOptions(): Object
Returns default options for getDateID()
.
Examples
getDateID(); // Date is 2019, May 22
// --> '190522'
getDateID({includeFullYear: true, order: 'mdy'});
// --> '05222019'
getDateID({includeFullYear: true, order: 'mdy', separateEach: true});
// --> '05-22-2019'
getTimeID(); // Time is 12:20:25am, Rome,Italy
// --> '002025+02'
getTimeID(); // Time is 4:20:25pm, Denver Daylight-Savings-Time
// --> '162025-06'
getTimeID({separateEach:true});
// --> '16-20-25-06'
getTimeID({separateEach:true, separator: '__'});
// --> '16__20__25-06'
getTimeID({separateEach:true, separator: '__', order: 'smh'});
// --> '25__20__16-06'
Installation
npm i @writetome51/get-date-id-time-id
Loading
// if using TypeScript:
import {getDateID, getTimeID, getDefaultsFor_getTimeIDOptions,
getDefaultsFor_getDateIDOptions} from '@writetome51/get-date-id-time-id';
// if using ES5 JavaScript:
var getDateID = require('@writetome51/get-date-id-time-id').getDateID;
var getTimeID = require('@writetome51/get-date-id-time-id').getTimeID;
var getDefaultsFor_getTimeIDOptions =
require('@writetome51/get-date-id-time-id').getDefaultsFor_getTimeIDOptions;
var getDefaultsFor_getDateIDOptions =
require('@writetome51/get-date-id-time-id').getDefaultsFor_getDateIDOptions;