public void SetsTheCorrectFormat( string localizedFormat, string expectedFormat) { var timeFormat = TimeFormat.FromLocalizedTimeFormat(localizedFormat); timeFormat.Format.Should().Be(expectedFormat); }
protected SelectTimeParameters CreateParameter(DateTimeOffset start, DateTimeOffset?stop, BeginningOfWeek beginningOfWeek = BeginningOfWeek.Sunday) { var dateFormat = DateFormat.FromLocalizedDateFormat("MM.DD.YYYY"); var timeFormat = TimeFormat.FromLocalizedTimeFormat("H:mm"); return(SelectTimeParameters .CreateFromOrigin(StartTime, beginningOfWeek, start, stop) .WithFormats(dateFormat, timeFormat)); }
protected SelectTimeParameters CreateParameter(DateTimeOffset start, DateTimeOffset?stop) { var dateFormat = DateFormat.FromLocalizedDateFormat("MM.DD.YYYY"); var timeFormat = TimeFormat.FromLocalizedTimeFormat("H:mm"); return(SelectTimeParameters .CreateFromBindingString("StartTime", start, stop) .WithFormats(dateFormat, timeFormat)); }
public void ThrowsForUnsupportedFormats(string format) { if (format == "h:mm A" || format == "H:mm") { return; } Action fromFormat = () => TimeFormat.FromLocalizedTimeFormat(format); fromFormat.Should().Throw <ArgumentException>(); }
public async Task SetsTimeOfDayFormat(string timeFormat) { var(togglClient, user) = await SetupTestUser(); var oldPreferences = await togglClient.Preferences.Get(); var newPreferences = new Preferences(oldPreferences); newPreferences.TimeOfDayFormat = TimeFormat.FromLocalizedTimeFormat(timeFormat); await togglClient.Preferences.Update(newPreferences); var updatedPreferences = await togglClient.Preferences.Get(); updatedPreferences.TimeOfDayFormat.Should().Be(newPreferences.TimeOfDayFormat); }
public static IEnumerable <object[]> TimeFormats() => new List <object[]> { new object[] { TimeFormat.FromLocalizedTimeFormat("h:mm A") }, new object[] { TimeFormat.FromLocalizedTimeFormat("H:mm") } };
public void SetsTheCorrectLocalizedFormat(string localizedFormat) { var timeFormat = TimeFormat.FromLocalizedTimeFormat(localizedFormat); timeFormat.Localized.Should().Be(localizedFormat); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, Newtonsoft.Json.JsonSerializer serializer) => TimeFormat.FromLocalizedTimeFormat(reader.Value.ToString());