I'm trying to put together a tool that will help me make work schedules. What is the easiest way to solve the following?
and so on.
These can all be done with DateTime.Add(TimeSpan)
since it supports positive and negative timespans.
DateTime original = new DateTime(year, month, day, 8, 0, 0); DateTime updated = original.Add(new TimeSpan(5,0,0)); DateTime original = new DateTime(year, month, day, 17, 0, 0); DateTime updated = original.Add(new TimeSpan(-2,0,0)); DateTime original = new DateTime(year, month, day, 17, 30, 0); DateTime updated = original.Add(new TimeSpan(0,-45,0));
Or you can also use the DateTime.Subtract(TimeSpan)
method analogously.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With