Free cookie consent management tool by TermsFeed Policy Generator

Changeset 14025 for trunk/sources


Ignore:
Timestamp:
07/08/16 14:16:05 (8 years ago)
Author:
pfleck
Message:

#2610 Use TimeSpan.TryParseExact to avoid parsing illegal strings, e.g "24:00:00" since h must be 0-23.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Data/3.3/TimeSpanValue.cs

    r12012 r14025  
    2121
    2222using System;
     23using System.Globalization;
    2324using System.Text;
    2425using HeuristicLab.Common;
     
    5253    protected virtual bool Validate(string value, out string errorMessage) {
    5354      TimeSpan val;
    54       bool valid = TimeSpan.TryParse(value, out val);
     55      bool valid = TimeSpan.TryParseExact(value, "c", CultureInfo.CurrentCulture, out val);
    5556      errorMessage = string.Empty;
    5657      if (!valid) {
     
    6869    protected virtual bool SetValue(string value) {
    6970      TimeSpan val;
    70       if (TimeSpan.TryParse(value, out val)) {
     71      if (TimeSpan.TryParseExact(value, "c", CultureInfo.CurrentCulture, out val)) {
    7172        Value = val;
    7273        return true;
Note: See TracChangeset for help on using the changeset viewer.