public void Load(String pathToLotos, String primeFilename, String pathToOrlen) { if (!File.Exists(pathToLotos)) { throw new ArgumentException("pathToLotos targets an invalid file"); } if (!File.Exists(primeFilename)) { throw new ArgumentException("primeFilename targets an invalid file"); } if (!File.Exists(pathToOrlen)) { throw new ArgumentException("pathToOrlen targets an invalid file"); } try { LoadIndexes(pathToLotos, _lotosIndexes, type.lotos); LoadIndexes(primeFilename, _rates, type.rate); LoadIndexes(pathToOrlen, _orlenIndexes, type.orlen); } catch { throw new NotSupportedException("Loading file failed. Not supported file format. Make sure column headers are written in the file"); } MaxDate = MaxDate.Subtract(new TimeSpan(_inputSize, 0, 0, 0)); StitchFinancialIndexes(); _samples.Sort(); NormalizeData(); }
protected override void AddAttributesToRender(HtmlTextWriter writer) { AddAttributesToRender(writer); if (RenderUplevel) { if (Helpers.EnableLegacyRendering()) { writer.AddAttribute("evaluationfunction", "ClientValidateDate", false); writer.AddAttribute("required", Required.ToString().ToLower(), false); writer.AddAttribute("dateSeparator", CultureInfo.CurrentCulture.DateTimeFormat.DateSeparator, false); writer.AddAttribute("shortDatePattern", CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern, false); writer.AddAttribute("minDate", MinDate.ToString(), false); writer.AddAttribute("maxDate", MaxDate.ToString(), false); writer.AddAttribute("invalidErrorMessage", InvalidErrorMessage, true); writer.AddAttribute("requiredErrorMessage", RequiredErrorMessage, true); } else { Page.ClientScript.RegisterExpandoAttribute(ClientID, "evaluationfunction", "ClientValidateDate", false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "required", Required.ToString().ToLower(), false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "dateSeparator", CultureInfo.CurrentCulture.DateTimeFormat.DateSeparator, false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "shortDatePattern", CultureInfo.CurrentCulture.DateTimeFormat.ShortDatePattern, false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "minDate", MinDate.ToString(), false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "maxDate", MaxDate.ToString(), false); Page.ClientScript.RegisterExpandoAttribute(ClientID, "invalidErrorMessage", InvalidErrorMessage, true); Page.ClientScript.RegisterExpandoAttribute(ClientID, "requiredErrorMessage", RequiredErrorMessage, true); } } }
public override byte[] ToBytes() { return(TLUtils.Combine( TLUtils.SignatureToBytes(Signature), Peer.ToBytes(), MaxDate.ToBytes())); }
public override void ToStream(Stream output) { output.Write(TLUtils.SignatureToBytes(Signature)); Peer.ToStream(output); MaxDate.ToStream(output); }
/** * Validates a property based on the property name and property value. * @param propertyName The name of the property to be checked. * @param propertyValue The value of the property to be checked. * @returns true if the property is valid, false otherwise. */ public new static bool ValidateProperty(string propertyName, string propertyValue) { bool isPropertyValid = WidgetBaseWindowsPhone.ValidateProperty(propertyName, propertyValue); if (propertyName.Equals("maxdateyear") || propertyName.Equals("maxdatemonth") || propertyName.Equals("maxdateday") || propertyName.Equals("mindateyear") || propertyName.Equals("mindatemonth") || propertyName.Equals("mindateday")) { int value; if (!int.TryParse(propertyValue, out value)) { isPropertyValid = false; } if (propertyName.Equals("maxdateyear")) { if (MinDate > MaxDate.AddYears(-1 * (MaxDate.Year - value)) || value > MaxYear) isPropertyValid = false; } else if (propertyName.Equals("maxdatemonth")) { if (value <= 12 && value >= 1) { if (MinDate > MaxDate.AddMonths(-1 * (MaxDate.Month - value))) isPropertyValid = false; } else { isPropertyValid = false; } } else if (propertyName.Equals("maxdateday")) { int month = MaxDate.Month; if (MinDate > MaxDate.AddDays(value - MaxDate.Day)) isPropertyValid = false; // If the month have changed it means that the day value was not valid. if (month != MaxDate.AddDays(value - MaxDate.Day).Month) isPropertyValid = false; } else if (propertyName.Equals("mindateyear")) { if (MinDate.AddYears(-1 * (MinDate.Year - value)) > MaxDate || value < MinYear) isPropertyValid = false; } else if (propertyName.Equals("mindatemonth")) { if (value <= 12 && value >= 1) { if (MinDate.AddMonths(-1 * (MinDate.Month - value)) > MaxDate) isPropertyValid = false; } else { isPropertyValid = false; } } else if (propertyName.Equals("mindateday")) { int month = MinDate.Month; if (MinDate.AddDays(value - MinDate.Day) > MaxDate) isPropertyValid = false; // IF the month have changed it means that the day value was not valid. if (month != MinDate.AddDays(value - MinDate.Day).Month) isPropertyValid = false; } } return isPropertyValid; }
public override int GetHashCode() { unchecked { var hashCode = NumberOfGamesToRetrieve; hashCode = (hashCode * 397) ^ BoardGameGeekGameDefinitionId.GetHashCode(); hashCode = (hashCode * 397) ^ MaxDate.GetHashCode(); return(hashCode); } }
public string Valid(string Name, string DateOfBirth, string Address, string Email) { String Error = ""; DateTime DateTemp; DateTime MinDate = new DateTime(1900, 1, 1); DateTime MaxDate; MaxDate = DateTime.Now.Date; MaxDate = MaxDate.AddYears(-13); if (Name.Length == 0) { Error = Error + "Name may not be blank. "; } if (Name.Length > 50) { Error = Error + "Name may not be longer than 50 characters. "; } try { DateTemp = Convert.ToDateTime(DateOfBirth); if (DateTemp < MinDate) { Error = Error + "The date cannot be earlier than 1/01/1900. "; } if (DateTemp > MaxDate) { Error = Error + "The date cannot be later than today's date minus 13 years. "; } } catch { Error = Error + "Invalid date. "; } if (Address.Length == 0) { Error = Error + "Address may not be blank. "; } if (Address.Length > 50) { Error = Error + "Address may not be longer than 50 characters. "; } if (Email.Length == 0) { Error = Error + "Email may not be blank. "; } if (Email.Length > 50) { Error = Error + "Email may not be longer than 50 characters. "; } return(Error); }
/// <summary> /// Initialize partitioning configuration for partitioned table. Normally populated from a configuration database. /// </summary> /// <param name="model">Parent model.</param> /// <param name="PartitioningConfigurationID">ID of the PartitioningConfiguration table.</param> /// <param name="granularity">Partition granularity, which can be Yearly, Monthly or Daily.</param> /// <param name="numberOfPartitionsFull">Count of all partitions in the rolling window. For example, a rolling window of 10 years partitioned by month would result in 120 partitions.</param> /// <param name="numberOfPartitionsForIncrementalProcess">Count of “hot partitions” where the data can change. For example, it may be necessary to refresh the most recent 3 months of data every day. This only applies to the most recent partitions.</param> /// <param name="maxDateIsNow">Assumes maximum date to be accounted for is today.</param> /// <param name="maxDate">The maximum date that needs to be accounted for in the partitioned table. Represents the upper boundary of the rolling window.</param> /// <param name="integerDateKey">Assumes date keys are integers. If false assumes date type.</param> /// <param name="templateSourceQuery">Template query used for partition source queries.</param> public PartitioningConfiguration( int partitioningConfigurationID, Granularity granularity, int numberOfPartitionsFull, int numberOfPartitionsForIncrementalProcess, bool maxDateIsNow, DateTime maxDate, bool integerDateKey, string templateSourceQuery ) { PartitioningConfigurationID = partitioningConfigurationID; Granularity = granularity; NumberOfPartitionsFull = numberOfPartitionsFull; NumberOfPartitionsForIncrementalProcess = numberOfPartitionsForIncrementalProcess; if (maxDateIsNow) { MaxDate = GetNextWeekday(DateTime.Today, DayOfWeek.Wednesday); } else { MaxDate = maxDate; } IntegerDateKey = integerDateKey; TemplateSourceQuery = templateSourceQuery; switch (granularity) { case Granularity.Daily: LowerBoundary = MaxDate.AddDays(-numberOfPartitionsFull + 1); UpperBoundary = MaxDate; break; case Granularity.Monthly: LowerBoundary = Convert.ToDateTime(MaxDate.AddMonths(-numberOfPartitionsFull + 1).ToString("yyyy-MMM-01")); UpperBoundary = Convert.ToDateTime(MaxDate.AddMonths(1).ToString("yyyy-MMM-01")).AddDays(-1); break; case Granularity.Weekly: LowerBoundary = GetNextWeekday(MaxDate.AddDays((-numberOfPartitionsFull + 1) * 7), DayOfWeek.Wednesday); UpperBoundary = GetNextWeekday(MaxDate, DayOfWeek.Wednesday); break; case Granularity.Yearly: LowerBoundary = Convert.ToDateTime(MaxDate.AddYears(-numberOfPartitionsFull + 1).ToString("yyyy-01-01")); UpperBoundary = Convert.ToDateTime(MaxDate.AddYears(1).ToString("yyyy-01-01")).AddDays(-1); break; default: break; } }
public override byte[] ToBytes() { return(TLUtils.Combine( TLUtils.SignatureToBytes(Signature), Flags.ToBytes(), Peer.ToBytes(), Query.ToBytes(), Filter.ToBytes(), MinDate.ToBytes(), MaxDate.ToBytes(), Offset.ToBytes(), MaxId.ToBytes(), Limit.ToBytes())); }
///// <summary> ///// Valida uma entrada de DateTime. ///// </summary> ///// <param name="value">Data</param> ///// <returns>Booleano indicando se é data válida.</returns> //public override bool IsValid(object value) //{ // var isDateTime = false; // DateTime dateValue; // if (value != null && DateTime.TryParse(value.ToString(), out dateValue)) // { // isDateTime = MinDate <= dateValue && dateValue <= MaxDate // && (MinAnos == 0 || MaxDate.AddYears(-MinAnos) >= dateValue) // && (MaxAnos == 0 || MaxDate <= dateValue.AddYears(MaxAnos)); // } // return isDateTime; //} /// <summary> /// Valida uma entrada de DateTime. /// </summary> /// <param name="value">Data</param> /// <returns>Booleano indicando se é data válida.</returns> public bool IsValidRangeDate(object value) { var isDateTime = false; DateTime dateValue; if (value != null && DateTime.TryParse(value.ToString(), out dateValue)) { isDateTime = MinDate <= dateValue && dateValue <= MaxDate && (MinAnos == 0 || MaxDate.AddYears(-MinAnos) >= dateValue) && (MaxAnos == 0 || MaxDate <= dateValue.AddYears(MaxAnos)); } return(isDateTime); }
public override byte[] ToBytes() { return(TLUtils.Combine( TLUtils.SignatureToBytes(Signature), Flags.ToBytes(), Peer.ToBytes(), Query.ToBytes(), ToBytes(FromId, Flags, (int)SearchFlags.FromId), Filter.ToBytes(), MinDate.ToBytes(), MaxDate.ToBytes(), OffsetId.ToBytes(), AddOffset.ToBytes(), Limit.ToBytes(), MaxId.ToBytes(), MinId.ToBytes(), Hash.ToBytes())); }
protected void ComputeDateRange(IEnumerable <IHistogramable> items) { if (items == null) { throw new ArgumentNullException("items"); } foreach (IHistogramable h in items) { DateTime dt = (DateTime)h.BucketSelector; if (MinDate.CompareTo(dt) > 0) { MinDate = dt; } if (MaxDate.CompareTo(dt) < 0) { MaxDate = dt; } } }
public static DateTime GetNextSchedDate() { AppDbContext db = new AppDbContext(); DateTime MaxDate; DateTime NextDate; if (db.Schedules.Count() == 0) { MaxDate = new DateTime(2018, 5, 03); } else { MaxDate = db.Schedules.Max(s => s.EndDate); } NextDate = MaxDate.AddDays(1); return(NextDate); }
/// <summary> /// Checks the answer for correctness. /// </summary> /// <param name="answer"> the answer</param> /// <returns>the correct answer</returns> public override string CheckedAnswer(string answer) { string answerText = ""; DateTime date; if (!DateTime.TryParseExact(answer, SurveyConst.FormatDate, CultureInfo.CurrentCulture, DateTimeStyles.None, out date)) { throw new SurveyException(ErrorMessages.DateFormatError); } if (date > MaxDate) { throw new SurveyException($"{ErrorMessages.DateMustBeLess} {MaxDate.ToString(SurveyConst.FormatDate)}!"); } if (date < MinDate) { throw new SurveyException($"{ErrorMessages.DateMustBeGreater} {MinDate.ToString(SurveyConst.FormatDate)}!"); } answerText = answer; return(answerText); }
public override int GetHashCode() => IFrame.GetHashCode() ^ Keys.GetHashCode() ^ MaxDate.GetHashCode();
protected override void UpdatePicker(UIDatePicker picker) { picker.Mode = GetMode(); picker.MinimumDate = MinDate == DateTime.MinValue ? (NSDate)null : (NSDate)MinDate.ToUniversalTime(); picker.MaximumDate = MaxDate == DateTime.MaxValue ? (NSDate)null : (NSDate)MaxDate.ToUniversalTime(); picker.Date = (Value ?? DateTime.Now).ToUniversalTime(); }
public void Load(List <PredicInput> listdata, bool isnomalsize = true) { MaxDate = MaxDate.Subtract(new TimeSpan(_inputSize, 0, 0, 0)); /*Subtract 10 last days*/ _samples.Clear(); foreach (var data in listdata) { _samples.Add(data); foreach (PredicInputIndexe index in Enum.GetValues(typeof(PredicInputIndexe))) { var amount = data.GetValue((int)index); if (amount > _dicMaxValue[(int)index]) { _dicMaxValue[(int)index] = amount; } if (amount < _dicMinValue[(int)index]) { _dicMinValue[(int)index] = amount; } } if (MaxDate.Date < data.Date) { MaxDate = data.Date; } if (MinDate.Date > data.Date) { MinDate = data.Date; } } _samples.Sort(); /*Sort by date*/ //increa max and deincrea min 5 point/ foreach (PredicInputIndexe index in Enum.GetValues(typeof(PredicInputIndexe))) { _dicMaxValue[(int)index] += 5; _dicMinValue[(int)index] -= 5; } /* using (StreamWriter writer = new StreamWriter("Datasamples.csv")) * { * for (int i = 0; i < _samples.Count; i++) * { * System.Text.StringBuilder builder = new System.Text.StringBuilder(); * * builder.Append(_samples[i].Date.ToShortDateString()); * * foreach (PredicInputIndexe index in Enum.GetValues(typeof(PredicInputIndexe))) * { * * if (_samples[i].IsSetValue((int)index)) * { * builder.Append(","); * builder.Append(_samples[i].GetValue((int)index).ToString()); * } * } * writer.WriteLine(builder.ToString()); * } * } */ if (isnomalsize) { NormalizeData(); } }
public void EditMatchDate(DateTime newMatchDate) { if (newMatchDate.Date < MinDate.Date) { throw new ArgumentOutOfRangeException($"Date cannot be edited to earlier than {MinDate.ToShortDateString()}"); } if (newMatchDate.Date > MaxDate.Date) { throw new ArgumentOutOfRangeException($"Date cannot be edited to later than {MaxDate.ToShortDateString()}"); } Value = newMatchDate; }
private IEnumerable <AuditInfo> GetAudit() { foreach (IAudit audit in _allAudit.Where(a => a.OperationDate >= MinDate && a.OperationDate < MaxDate.AddDays(1))) { AuditInfo info = new AuditInfo { Quantity = audit.Quantity, OperationDate = audit.OperationDate.ToLocalTime().ToString("G"), IsFoil = audit.IsFoil.HasValue && audit.IsFoil.Value, IsAltArt = audit.IsAltArt.HasValue && audit.IsAltArt.Value, }; ICardCollection cardCollection = _magicDatabase.GetCollection(audit.IdCollection); info.CollectionName = cardCollection == null ? "(Deleted) " + audit.IdCollection : cardCollection.Name; if (audit.IdGatherer.HasValue) { ICard card = _magicDatabase.GetCard(audit.IdGatherer.Value); if (card == null) { info.CardName = "(Not found) " + audit.IdGatherer.Value; info.EditionName = "(Not found) " + audit.IdGatherer.Value; } else { info.CardName = card.Name; IEdition edition = _magicDatabase.GetEdition(audit.IdGatherer.Value); info.EditionName = edition == null ? "(Not found) " + audit.IdGatherer.Value : edition.Name; } if (audit.IdLanguage.HasValue) { ILanguage language = _magicDatabase.GetLanguage(audit.IdLanguage.Value); info.Language = language == null ? "(Not found) " + audit.IdLanguage.Value : language.Name; } else { info.Language = "(Missing language)"; } } yield return(info); } }
protected bool Equals(RecentlyPlayedGamesFilter other) { return(NumberOfGamesToRetrieve == other.NumberOfGamesToRetrieve && BoardGameGeekGameDefinitionId == other.BoardGameGeekGameDefinitionId && MaxDate.Equals(other.MaxDate)); }