]> git.ipfire.org Git - thirdparty/paperless-ngx.git/commitdiff
simplify date value format
authorMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Sun, 7 Aug 2022 04:19:06 +0000 (21:19 -0700)
committerMichael Shamoon <4887959+shamoon@users.noreply.github.com>
Sun, 7 Aug 2022 04:19:06 +0000 (21:19 -0700)
src-ui/src/app/components/common/input/date/date.component.ts

index cf475df5e22fd0d3c1b798c8d02ef9c47e8f8ce7..63a15709b77b4547474908eb1f4f5a5a12664476 100644 (file)
@@ -53,17 +53,11 @@ export class DateComponent
   }
 
   onSuggestionClick(dateString: string) {
-    const parsedNgDate = this.ngbDateParserFormatter.parse(dateString)
-    this.writeValue(this.formatDateAsYYYYMMDD(parsedNgDate))
+    const parsedDate = this.ngbDateParserFormatter.parse(dateString)
+    this.writeValue(`${parsedDate.year}-${parsedDate.month}-${parsedDate.day}`)
     this.onChange(this.value)
   }
 
-  formatDateAsYYYYMMDD(date: NgbDateStruct) {
-    const monthPrefix = date.month > 9 ? '' : '0'
-    const dayPrefix = date.day > 9 ? '' : '0'
-    return `${date.year}-${monthPrefix}${date.month}-${dayPrefix}${date.day}`
-  }
-
   ngOnInit(): void {
     super.ngOnInit()
     this.placeholder = this.settings.getLocalizedDateInputFormat()