Distance bug fix
This commit is contained in:
		| @ -5,20 +5,12 @@ namespace View_by_Distance.Shared.Models.Stateless.Methods; | ||||
| internal abstract class PersonBirthday | ||||
| { | ||||
|  | ||||
|     internal static DateTime GetDefaultValue() => DateTime.MinValue; // {{1}}SingletonValue | ||||
|  | ||||
|     // ... | ||||
|     internal static string GetFormatted(string personBirthdayFormat, Models.PersonBirthday personBirthday) => personBirthday.Value.ToString(personBirthdayFormat); | ||||
|     internal static string GetFileName(string personBirthdayFormat, Models.PersonBirthday personBirthday) => $"{personBirthday.Value.ToString(personBirthdayFormat)}.json"; | ||||
|     internal static bool DoesBirthDateExits(Properties.IStorage storage, string personBirthdayFormat, Models.PersonBirthday personBirthday) => File.Exists(GetFileFullName(storage, personBirthdayFormat, personBirthday)); | ||||
|     internal static Models.PersonBirthday GetNextBirthDate(Properties.IStorage storage) => throw new Exception(storage.ToString()); // Person.GetNextBirthDate(storage); | ||||
|     internal static string GetFileFullName(Properties.IStorage storage, string personBirthdayFormat, Models.PersonBirthday personBirthday) => Path.Combine(storage.PeopleRootDirectory, "{}", GetFileName(personBirthdayFormat, personBirthday)); | ||||
|     internal static DateTime? GetDateTime(string personBirthdayFormat, string personKey) => DateTime.TryParseExact(personKey.Replace('#', '0'), personBirthdayFormat, CultureInfo.InvariantCulture, DateTimeStyles.None, out DateTime dateTime) ? dateTime : null; | ||||
|  | ||||
|     internal static Models.PersonBirthday? GetPersonBirthday(string personBirthdayFormat, string personKey) | ||||
|     { | ||||
|         Models.PersonBirthday? result; | ||||
|         DateTime? dateTime = GetDateTime(personBirthdayFormat, personKey); | ||||
|         DateTime? dateTime = IPersonBirthday.GetDateTime(personBirthdayFormat, personKey); | ||||
|         if (dateTime is null) | ||||
|             result = null; | ||||
|         else | ||||
| @ -29,7 +21,7 @@ internal abstract class PersonBirthday | ||||
|     internal static bool IsCounterPersonBirthday(Models.PersonBirthday personBirthday) | ||||
|     { | ||||
|         bool result; | ||||
|         if (personBirthday.Value.Year < 1900) | ||||
|         if (personBirthday.Value.Year < 1826) | ||||
|             result = true; | ||||
|         else | ||||
|             result = false; | ||||
| @ -109,7 +101,7 @@ internal abstract class PersonBirthday | ||||
|         return result; | ||||
|     } | ||||
|  | ||||
|     internal static Models.PersonBirthday[] GetDescendingOrderedPersonBirthdays(string personBirthdayFormat, string[] personKeyDirectories, string personDisplayDirectory) | ||||
|     internal static List<Models.PersonBirthday> GetPersonBirthdays(string personBirthdayFormat, string[] personKeyDirectories, string personDisplayDirectory, string personDisplayDirectoryName) | ||||
|     { | ||||
|         List<Models.PersonBirthday> results = new(); | ||||
|         string[] files; | ||||
| @ -124,13 +116,15 @@ internal abstract class PersonBirthday | ||||
|                 (personBirthday, personKeyFormatted) = Person.Get(personBirthdayFormat, personDisplayDirectory, personKeyDirectory, birthday); | ||||
|             if (personBirthday is null || personKeyFormatted.Contains('#')) | ||||
|                 continue; | ||||
|             if (!IPersonBirthday.IsCounterPersonBirthday(personBirthday) && ((!personKeyDirectory.Contains('#') && (personDisplayDirectoryName.Contains('~') || personDisplayDirectoryName.Contains('#'))) || (personKeyDirectory.Contains('#') && !personDisplayDirectoryName.Contains('#')))) | ||||
|                 throw new NotSupportedException(); | ||||
|             results.Add(personBirthday); | ||||
|             files = Directory.GetFiles(personKeyDirectory, "*", SearchOption.TopDirectoryOnly); | ||||
|             if (files.Any()) | ||||
|                 continue; | ||||
|             File.WriteAllText(Path.Combine(personKeyDirectory, $"{personKeyFormatted}.txt"), string.Empty); | ||||
|         } | ||||
|         return results.OrderByDescending(l => l.Value.Ticks).ToArray(); | ||||
|         return results; | ||||
|     } | ||||
|  | ||||
| } | ||||
		Reference in New Issue
	
	Block a user