Ext.define('Ext.ux.form.field.AutoTimeStamp', {
	
	extend: 'Ext.form.field.Text',

	alias: ['widget.autotimestampfield'],

	hidden: true,

	enforceRecordValue: true,

	initComponent: function () {

		var i_cmp = this;

		i_cmp.callParent(arguments);

		return i_cmp;
	},
	
	addLeadingZero: function (n_val) {

		var s_val = String(n_val);

		if (s_val.length == 1) {
			s_val = '0' + s_val;
		}

		return s_val;
	},
	
	getValue: function () {

		var i_cmp = this;
		var i_timestamp = new Date();

		var s_date = [
			i_timestamp.getFullYear(),
			i_cmp.addLeadingZero(i_timestamp.getMonth() + 1),
			i_cmp.addLeadingZero(i_timestamp.getDate())
		].join('-');

		var s_time = [
			i_cmp.addLeadingZero(i_timestamp.getHours()),
			i_cmp.addLeadingZero(i_timestamp.getMinutes()),
			i_cmp.addLeadingZero(i_timestamp.getSeconds()),
			i_timestamp.getMilliseconds() + '000'
		].join('.');

		return [s_date, s_time].join('-');
	},
	
	getSubmitValue: function () {

		return this.getValue();
	},

	setValue: function () {

		var i_cmp = this;
		var s_value = i_cmp.getValue();

		return i_cmp.callParent([s_value]);
	},
	
	isDirty: function () {

		return false;
	}
});
