Bläddra i källkod

change date limitation from week to month

Ami123456 1 vecka sedan
förälder
incheckning
50505c849c
1 ändrade filer med 28 tillägg och 2 borttagningar
  1. 28 2
      src/app/createentry/dvrentry.component.ts

+ 28 - 2
src/app/createentry/dvrentry.component.ts

@@ -238,9 +238,17 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
 
 
     this.current_date = new Date();
+    // console.log(this.current_date);
+    // console.log(this.current_date - 7);
     var dd = this.current_date.getDate();
+    // console.log(this.current_date.getDate())
+    // console.log(dd);
     var mm = this.current_date.getMonth() + 1;
+    // console.log(this.current_date.getMonth());
+    // console.log(mm);
     var yyyy = this.current_date.getFullYear();
+    // console.log(dd);
+    // console.log(mm);
     if (dd < 10) {
       dd = '0' + dd
     }
@@ -256,7 +264,15 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
     var dd1;
     //console.log("dddddddd------->", this.current_date.getDate() - 7);
 
-    var date = dd - 7;
+    // var date = dd - 7;
+    var date = dd;
+    this.mincurrent_date = new Date();
+    var min_mm = this.mincurrent_date.getMonth();
+
+    // console.log(min_mm);
+    if (min_mm < 10) {
+      min_mm = '0' + min_mm;
+    }
     console.log("date====>", date);
 
     if (date < 10) {
@@ -265,10 +281,20 @@ export class DvrEntryComponent implements OnInit, OnDestroy {
       dd1 = date;
     }
 
+    console.log(yyyy - 1);
+
+    if (min_mm == "00") {
+      min_mm = 11;
+      yyyy = yyyy - 1;
+    }
+
     console.log("dd1-------->", dd1)
 
 
-    this.mincurrent_date = yyyy + '-' + mm + '-' + dd1;
+    // this.mincurrent_date = yyyy + '-' + mm + '-' + dd1;
+    this.mincurrent_date = yyyy + '-' + min_mm + '-' + dd1;
+
+    console.log("min date------>", this.mincurrent_date);
     document.getElementById("Date").setAttribute("min", this.mincurrent_date);