I’m working on using some if statement to check if the system month is between a certain range to sort of compensate for daylight savings times.
if (sysMonth == 01) {
yield return new WaitForSeconds (0.5f); // wait time
VoiceBox VBbr = FindObjectOfType<VoiceBox> ();
VBbr.BrightnessDetected ();
MessageCentreManager MCMbd = FindObjectOfType<MessageCentreManager> ();
MCMbd.GoBrightnessDetectedMessage ();
print ("Brilliant Light Detected Michael");
}
Something like that.
I’m wondering if I’m on the right track and I need something like:
if (sysMonth >=10 && sysMonth <= 02) //October to Feb.
Am I on the right track with that or way off the mark? I always have a hard time wrapping my head around that stuff ![:wink: :wink:](https://emoji.discourse-cdn.com/google/wink.png?v=12)
You can determine whether DST is active in the current time zone by calling DateTime.Now.IsDaylightSavingTime()
. It returns true
if DST is active. You can find DST delta (that is, how much time is advanced when DST is active) by accessing TimeZone.CurrentTimezone.GetDaylightChanges(DateTime.Now.Year).Delta
. All this is from System
namespace.
DateTime now = DateTime.Now;
TimeZone tz = TimeZone.CurrentTimeZone;
TimeSpan delta = tz.GetDaylightChanges(now.Year).Delta;
bool isDST = now.IsDaylightSavingTime();
Then you can make your adjustments based on this.
HTH
I wonder if what I need is to use the || “or” instead of && “Or” and so that the argument is something like:
(sysMonth <= 2 || sysMonth >= 10) { //Jan. to Oct.
So that System Month is Less or equals to 2 (less than or equals to February)
OR
System month is greater than or equals to 10 (October)
That way system month has to be greater than 10 to be beyond or past October?
Maybe I’m not fully understanding it right but in my head that sound logical, Am I baked in assuming that?