/// <summary> /// Get the format for the time string /// </summary> /// <param name="targetFormat">Type of format</param> /// <param name="timeLong">Show date with weekday and name of month (long format)</param> /// <param name="dateLong">Show time with seconds (long format)</param> /// <returns>String that identifies the time/date format (<see href="https://docs.microsoft.com/en-us/dotnet/api/system.datetime.tostring"/>)</returns> internal static string GetStringFormat(FormatStringType targetFormat, bool timeLong, bool dateLong) { switch (targetFormat) { case FormatStringType.Time: return(timeLong ? "T" : "t"); case FormatStringType.Date: return(dateLong ? "D" : "d"); case FormatStringType.DateTime: if (timeLong & dateLong) { return("F"); // Friday, October 31, 2008 5:04:32 PM } else if (timeLong & !dateLong) { return("G"); // 10/31/2008 5:04:32 PM } else if (!timeLong & dateLong) { return("f"); // Friday, October 31, 2008 5:04 PM } else { // (!timeLong & !dateLong) return("g"); // 10/31/2008 5:04 PM } default: return(string.Empty); // Windows default based on current culture settings } }
public FormatString(FormatStringType type, string fmt) { FormatType = type; Value = fmt; }