Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
The following code
long ticks = 604094112000000000;
TimeSpan offset = TimeSpan.Zero;
var dto = new DateTimeOffset(ticks, offset);
dto.ToLocalTime(); // error!
Results in the following error:
System.ArgumentException: Offset must be specified in whole minutes. Parameter name: offset at System.DateTimeOffset.ValidateOffset (System.TimeSpan offset) <0x7fd626f5e760 + 0x000c7> in <filename unknown>:0 at System.DateTimeOffset..ctor (System.DateTime dateTime) <0x7fd626f5c150 + 0x00064> in <filename unknown>:0 at System.DateTimeOffset.ToLocalTime (System.Boolean throwOnOverflow) <0x7fd626f5e2a0 + 0x00058> in <filename unknown>:0 at System.DateTimeOffset.ToLocalTime () <0x7fd626f5e260 + 0x0001d> in <filename unknown>:0 at <InteractiveExpressionClass>.Host (System.Object& $retval) <0x40bbed70 + 0x00021> in <filename unknown>:0 at Mono.CSharp.Evaluator.Evaluate (System.String input, System.Object& result, System.Boolean& result_set) <0x40b2e280 + 0x000dd> in <filename unknown>:0 at Mono.CSharpShell.Evaluate (System.String input) <0x40b2e180 + 0x00053> in <filename unknown>:0
This does not occur when run with CLR. I can reproduce this with latest commits of the master branch (627709367794a53694497aea57aef66a8e088bcd).
I neglected to mention that that my local timezone has a +03:00 offset. This might be related to the issue.
I cannot reproduce the issue.
What `TimeZoneInfo.Local` says on your machine and what local time do you run it?
Apologies. My local TimeZoneInfo is 'Europe/Athens'.
My Local time (in ticks) that can reproduce the issue is 636009640251191610
For some reason I still cannot reproduce it. Could you give me output of following line on your machine?
Console.WriteLine (dto.UtcDateTime.ToLocalTime ().Ticks);
Console.WriteLine (dto.UtcDateTime.ToLocalTime ().Minute);
Btw, are you running this on Linux? I cannot reproduce the same problem in OSX.
I tested this on osx and linux mint and both work for me.
It looks like your linux version has some broken timezone info (or it's using some new/different features).
As I still cannot reproduce it locally.
What does TimeZoneInfo.Local.BaseUtcOffset show on your machine?
I'm using Ubuntu 16.04, you're probably right that this might be machine configuration related. Running the same code in a docker container does not reproduce the issue.
To answer your question, TimeZoneInfo.Local.BaseUtcOffset evaluates to 02:00:00
I am not sure what's special on your 16.04 machine but it looks like some local issue. Perhaps reinstalling TZ data would fix that
I'm reproducing the issue on a vanilla ubuntu server 16.04 running on Azure. Reproduction steps:
sudo timedatectl set-timezone Europe/Athens
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 3FA7E0328081BFF6A14DA29AA6A19B38D3D831EF
echo "deb http://download.mono-project.com/repo/debian wheezy main" | sudo tee /etc/apt/sources.list.d/mono-xamarin.list
sudo apt-get update
sudo apt-get install mono-complete
Fixed in master and Mono 4.5.1