Free cookie consent management tool by TermsFeed Policy Generator

Opened 9 years ago

Closed 8 years ago

#2610 closed enhancement (done)

TimeSpanValue Parse

Reported by: pfleck Owned by: pfleck
Priority: low Milestone: HeuristicLab 3.3.14
Component: Data.Views Version: 3.3.13
Keywords: Cc:

Description (last modified by gkronber)

TimeSpan.TryParse also tries to parse strings that do not satisfy the format exactly. In this case the results can be unexpected.

Seconds and minutes over 59, and hours over 23 are interpreted as days. Therefore, parsing "72:00:00" does not result in 72h = 3days, instead is treated as "72.00:00:00" = 72 days.

Although the view immediately updates the parsed value, one can easily overlook incorrectly parsed values.

This should be prohibited via validation error (see TimeSpan.TryParseExact).

Change History (11)

comment:1 Changed 8 years ago by gkronber

  • Component changed from ### Undefined ### to Data.Views
  • Description modified (diff)

comment:2 Changed 8 years ago by gkronber

  • Description modified (diff)

comment:3 Changed 8 years ago by pfleck

  • Owner set to pfleck
  • Status changed from new to accepted

comment:4 Changed 8 years ago by pfleck

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

The format specifier "c" (invariant) is used because it's format matches our defined TimeSpan format pattern. See HeuristicLab.Data/FormatPatterns.cs and https://msdn.microsoft.com/en-us/library/ee372286(v=vs.110).aspx.

comment:5 Changed 8 years ago by pfleck

  • Owner changed from pfleck to mkommend
  • Status changed from accepted to reviewing

comment:6 Changed 8 years ago by mkommend

  • Owner changed from mkommend to gkronber

comment:7 Changed 8 years ago by gkronber

  • Owner changed from gkronber to pfleck
  • Status changed from reviewing to assigned

Please use the same format string for ToString calls.

comment:8 Changed 8 years ago by pfleck

r14034 Added format specifier for ToString calls.

Although the parameterless ToString already use the "c" format specifier (see here) I added format specifier for consistency.

comment:9 Changed 8 years ago by pfleck

  • Owner changed from pfleck to gkronber
  • Status changed from assigned to reviewing

comment:10 Changed 8 years ago by gkronber

  • Owner changed from gkronber to pfleck
  • Status changed from reviewing to readytorelease

Ok thanks!

comment:11 Changed 8 years ago by mkommend

  • Resolution set to done
  • Status changed from readytorelease to closed

r14080: Merged r14025, r14034 to stable.

Note: See TracTickets for help on using tickets.