<commit_before>module.directive('authGrantForm', [
	'PartyAuthorize',
	'authService',
	'authPresetService',
	'$filter',
	'pageService',
	function (PartyAuthorize, authService, authPresetService, $filter, page) {
		var link = function ($scope) {
			var form = $scope.authGrantForm;

			var supportsDate = document.createElement('input');
			supportsDate.setAttribute('type', 'date');
			supportsDate = supportsDate.type === 'date';

			form.presets = authPresetService;
			form.party = $scope.party || authService.user;
			form.other = undefined;

			//

			var dateNow = new Date(),
				dateLimit = new Date((new Date()).setYear(dateNow.getFullYear() + 2));

			var transformInputDate = function () {
				var now = dateNow,
					limit = dateLimit.getTime(),
					exp = form.other.expiration.split('-'),
					trial = new Date(exp[1] + '-' + exp[2] + '-' + exp[0]).getTime();

				if (trial > limit || isNaN(trial))
					form.other.expiration = $filter('date')(limit, 'yyyy-MM-dd');

				if (trial < now.getTime())
					form.other.expiration = $filter('date')(now, 'yyyy-MM-dd');
			};

			var transformInputText = function () {

			};

			form.transformExpiration = function () {
				if (supportsDate)
					transformInputDate();
				else
					transformInputText();
			};

			//<commit_msg>authGrant expiration handling for non-Date browsers<commit_after>module.directive('authGrantForm', [
	'PartyAuthorize',
	'authService',
	'authPresetService',
	'$filter',
	'pageService',
	function (PartyAuthorize, authService, authPresetService, $filter, page) {
		var link = function ($scope) {
			var form = $scope.authGrantForm;

			var supportsDate = document.createElement('input');
			supportsDate.setAttribute('type', 'date');
			supportsDate = supportsDate.type === 'date';

			form.presets = authPresetService;
			form.party = $scope.party || authService.user;
			form.other = undefined;

			//

			var dateNow = new Date(),
				dateLimit = new Date((new Date()).setYear(dateNow.getFullYear() + 2));

			form.transformExpiration = function () {
				var now = dateNow,
					limit = dateLimit.getTime(),
					exp = form.other.expiration.split('-'),
					trial = new Date(supportsDate ? exp[1] + '-' + exp[2] + '-' + exp[0] : form.other.expiration).getTime();

				if (trial > limit || isNaN(trial))
					form.other.expiration = $filter('date')(limit, 'yyyy-MM-dd');

				if (trial < now.getTime())
					form.other.expiration = $filter('date')(now, 'yyyy-MM-dd');

				if (supportsDate)
					transformInputDate();
				else
					transformInputText();
			};

			//
{'fraction_non_alphanumeric': 0.1655577299412916, 'fraction_numerical': 0.0031311154598825833, 'mean_word_length': 3.6220614828209765, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3742297', 'n_tokens_mistral': 1002, 'n_tokens_neox': 808, 'n_words': 163}