Need some help with this script. When I run this script it works well. However, at the end of the day it freezes at evening. The following day when I run the script it starts at evening, and it should start by saying morning. Am I missing something?

string timeOfDay;

dialog getTimeOfDay (out string TOD) {
			string time = formatDate(now(), "HHmm");
			if (time =~ '(?:[0-1]) (?:[0-1]) (?:[0-5]) (?:[0-9])'){
					TOD = "morning";
			}//Closes Morning String
			elif (time =~ '(?:1) (?:[2-6]) (?:[-5]) (?:[0-9])') {
					TOD = "afternoon";
			}//Closes Afternoon String
			else TOD = "evening";

call getTimeOfDay(out timeOfDay);
string timeOfDay;

dialog getTimeOfDay (out string TOD) {
			string time = formatDate(now(), "HHmm");
			if (time =~ '(?:[0-1]) (?:[0-1]) (?:[0-5]) (?:[0-9])'){
					TOD = "morning";
			}//Closes Morning String
			elif (time =~ '(?:1) (?:[2-6]) (?:[-5]) (?:[0-9])') {
					TOD = "afternoon";
			}//Closes Afternoon String
			else TOD = "evening";

call getTimeOfDay(out timeOfDay);

Am I missing something?

The correct forum perhaps? This is the Java forum.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.