How to use the ilib/lib/DateFactory function in ilib

To help you get started, we’ve selected a few ilib examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github enactjs / enact / packages / moonstone / TimePicker / TimePicker.js View on Github external
onChangeHour: function (ev, value) {
			const currentTime = DateFactory(value).getTimeExtended();
			const currentHour = value.hour;

			value.hour = ev.value;

			// In the case of navigating onto the skipped hour of DST, ilib will return the same
			// value so we skip that hour and update the value again.
			const newTime = DateFactory(value).getTimeExtended();
			if (newTime === currentTime) {
				value.hour = ev.value * 2 - currentHour;
			}

			return value;
		},
github enactjs / enact / packages / moonstone / internal / DateTimeDecorator / DateTimeDecorator.js View on Github external
toIDate (time) {
			if (time && this.props.locale) {
				return DateFactory({
					unixtime: time,
					timezone: 'local'
				});
			}
		}
github enactjs / enact / packages / moonstone / internal / DateTimeDecorator / DateTimeDecorator.js View on Github external
updateValue = (value) => {
			const {day, month, year} = value;
			const maxDays = value.cal.getMonLength(month, year);
			value.day = (day <= maxDays) ? day : maxDays;

			const date = DateFactory(value);
			const newValue = date.getTimeExtended();
			const changed =	this.props.value == null || this.props.value !== newValue;

			this.setState({
				value: newValue
			});

			if (changed) {
				this.emitChange(date);
			}

			return newValue;
		}
github enactjs / enact / packages / moonstone / DatePicker / DatePicker.js View on Github external
const toLocalYear = (year) => {
			return DateFactory({
				julianday: DateFactory({
					year,
					type: 'gregorian',
					month: 1,
					day: 1,
					timezone: 'local'
				}).getJulianDay(),
				timezone: 'local'
			}).getYears();
		};
github enactjs / enact / packages / moonstone / DatePicker / DatePicker.js View on Github external
const toLocalYear = (year) => {
			return DateFactory({
				julianday: DateFactory({
					year,
					type: 'gregorian',
					month: 1,
					day: 1,
					timezone: 'local'
				}).getJulianDay(),
				timezone: 'local'
			}).getYears();
		};