On dark turn Led on and off in an hr

Thanks for the help
after few corrections now it works.

  1. ldr value starts increasing which should not i think
  2. for a moment if ldr goes down below 512 and back to normal still the light turns on.

Thanks

code
#define LDR 0
#define LED 13
#define LIGHTON 60000 //Time light is on when dark

int waiting_for_day;
unsigned long darkStart;
int ldrValue;

void setup(){
pinMode(LED, OUTPUT);
digitalWrite(LED, LOW);
Serial.begin(9600);
}
void loop(){
ldrValue = analogRead(LDR);

if (ldrValue <= 512 && waiting_for_day == 0 ){
digitalWrite(LED, HIGH);
darkStart = millis();
waiting_for_day = 1;
}
if (millis()-darkStart > LIGHTON ){
digitalWrite(LED, LOW);
darkStart = 0;
}
if ( ldrValue >=512){
waiting_for_day = 0; // daytime, can look for nighttime now

}
Serial.println(ldrValue);
Serial.println(darkStart);
Serial.println(waiting_for_day);
delay(500);
}