I have a string that represents the offset of a particular customer. An example is UTC+1:00
. It is always the offset relative to UTC, so the string will always start with UTC
followed by +
or -
and then the offset in format hh:mm
.
The question is, how can I take this string and convert it into an offset? I do not want a date and time object with an offset applied, I just want an object that symbolizes my offset, something I can then later apply to a date, which is something different altogether.
At the title says, I'm looking to use NodaTime for this.
It sounds like you want:
var pattern = OffsetPattern.CreateWithInvariantCulture("'UTC'+H:mm");
var offset = pattern.Parse(text).Value;
See more on this question at Stackoverflow