mirror of
				https://github.com/paperless-ngx/paperless-ngx.git
				synced 2025-11-04 03:27:12 -05:00 
			
		
		
		
	Always accept yyyy-mm-dd date inputs
This commit is contained in:
		
							parent
							
								
									317926f379
								
							
						
					
					
						commit
						e16ab324f4
					
				@ -51,11 +51,22 @@ export class LocalizedDateParserFormatter extends NgbDateParserFormatter {
 | 
				
			|||||||
    const dateSeparator = inputFormat.replace(/[dmy]/gi, '').charAt(0)
 | 
					    const dateSeparator = inputFormat.replace(/[dmy]/gi, '').charAt(0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (this.separatorRegExp.test(value)) {
 | 
					    if (this.separatorRegExp.test(value)) {
 | 
				
			||||||
      // split on separator, pad & re-join without separator
 | 
					      let segments = value.split(this.separatorRegExp)
 | 
				
			||||||
      value = value
 | 
					
 | 
				
			||||||
        .split(this.separatorRegExp)
 | 
					      // always accept strict yyyy*mm*dd format even if thats not the input format since we can be certain its not yyyy*dd*mm
 | 
				
			||||||
        .map((segment) => segment.padStart(2, '0'))
 | 
					      if (
 | 
				
			||||||
        .join('')
 | 
					        value.length == 10 &&
 | 
				
			||||||
 | 
					        segments.length == 3 &&
 | 
				
			||||||
 | 
					        segments[0].length == 4
 | 
				
			||||||
 | 
					      ) {
 | 
				
			||||||
 | 
					        return inputFormat
 | 
				
			||||||
 | 
					          .replace('yyyy', segments[0])
 | 
				
			||||||
 | 
					          .replace('mm', segments[1])
 | 
				
			||||||
 | 
					          .replace('dd', segments[2])
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        // otherwise pad & re-join without separator
 | 
				
			||||||
 | 
					        value = segments.map((segment) => segment.padStart(2, '0')).join('')
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    if (value.length == 4 && inputFormat.substring(0, 4) != 'yyyy') {
 | 
					    if (value.length == 4 && inputFormat.substring(0, 4) != 'yyyy') {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user