Example #1
0
 public override bool IsValid()
 {
     return((StartIsolation.CompareTo(ExtNodatime.InstantError) != 0) && (StartSymptoms?.CompareTo(ExtNodatime.InstantError) ?? 1) != 0);
 }
Example #2
0
        public string ValidateStartSymptoms(string startSymptomsLocal)
        {
            string rc = null;

            StartSymptoms = ExtNodatime.InstantError;

            if (string.IsNullOrEmpty(TzDbName) || (string.IsNullOrEmpty(CultureTag)))
            {
                rc = $"{ProgramErrorMsg} 220. Please report this problem.";
            }
            else
            {
                try
                {
                    DateTimeZone zone = DateTimeZoneProviders.Tzdb[TzDbName];
                    if (string.IsNullOrEmpty(startSymptomsLocal))
                    {
                        StartSymptoms = null;  //Ok, as value is optional
                    }
                    else
                    {
                        if (startSymptomsLocal.ParseDateTime(zone, CultureTag, WithoutDaylightSavings, MxCultureInfo.FormatType.DateTime, false, out var symptoms) == false)
                        {
                            rc = $"Please try again with a valid date/time like {SampleDateTime}";
                        }
                        else
                        {
                            var span = NowInstance - symptoms;
                            if (span.TotalSeconds < 0)
                            {
                                rc = $"This value is after the current time. Please try again with a value before {NowInstance.ToString(CultureTag, zone)}";
                            }
                            else
                            {
                                if (StartIsolation.IsError())
                                {
                                    rc = $"You must set the start of your self-isolation before giving the start of your symptoms";
                                }
                                else
                                {
                                    span = symptoms - StartIsolation;
                                    if (span.TotalSeconds < 0)
                                    {
                                        rc = $"This value is before the start of your self-isolation. If your symptoms started before you entered self-isolation then enter {StartIsolation.ToString(CultureTag, zone)}";
                                    }
                                    else
                                    {
                                        StartSymptoms = symptoms;
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception e)
                {
                    rc = $"{ProgramErrorMsg} 221. {e.Message}";
                }
            }
            return(rc);
        }