Sha256: 11698ffc70961c43561239d9bb44dfefae86396b96db18a5cf143982cfa215f3

Contents?: true

Size: 723 Bytes

Versions: 5

Compression:

Stored size: 723 Bytes

Contents

'use strict';
const timeZone = require('time-zone');

module.exports = options => {
	options = Object.assign({
		date: new Date(),
		local: true,
		showTimeZone: false,
		showMilliseconds: false
	}, options);

	let date = options.date;

	if (options.local) {
		// Offset the date so it will return the correct value when getting the ISO string
		date = new Date(date.getTime() - (date.getTimezoneOffset() * 60000));
	}

	let end = '';

	if (options.showTimeZone) {
		end = ' UTC' + (options.local ? timeZone(date) : '');
	}

	if (options.showMilliseconds && date.getUTCMilliseconds() > 0) {
		end = ` ${date.getUTCMilliseconds()}ms${end}`;
	}

	return date
		.toISOString()
		.replace(/T/, ' ')
		.replace(/\..+/, end);
};

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
jass-0.9.5 vendor/node_modules/date-time/index.js
jass-0.9.4 vendor/node_modules/date-time/index.js
jass-0.9.3 vendor/node_modules/date-time/index.js
condenser-0.0.4 lib/condenser/processors/node_modules/date-time/index.js
jass-0.9.1 vendor/node_modules/date-time/index.js