Browsing 7239 questions and answers with Jon Skeet

Custom JSON converter for Noda Time

I'm developing for .NET Core, so I'm using the unstable latest alpha of Noda Time (2.0.0-alpha20160729). Data is being handled with JSON. I will be accepting user input for a...
Jon Skeet
people
quotationmark

Firstly, this doesn't sound like the right thing to do in a JSON converter. If you're accepting user input directly in your JSON, that should be treated as a string, and parsed later, IMO. JSON is a machine-to-machine format, not a... more 9/7/2016 6:04:16 AM

people

Reoccurring events without year using DateTime

I am a junior programmer, just starting out. I have been given a task determining whether events (that will be occurring over and over again every year) are currently happening. ...
Jon Skeet
people
quotationmark

I would strongly recommend that you refactor your database to be more amenable to querying - you don't want to be having to parse the string values for every row, on every query. Additionally, you can add an extra field to indicate that... more 9/6/2016 1:36:45 PM

people

IE browser Date Time Issue

On IE 11 browser the below statement is returning an invalid date response: new Date("2016-03-09T22:40:05.653-0800"). Where as on the chrome/firefox it is returning the valid...
Jon Skeet
people
quotationmark

This is nearly an ISO-8601 formatted date/time, but not quite... the UTC offset doesn't have a colon in it. It looks like Chrome and Firefox aren't being quite as picky with their ISO-8601 parsing as IE. If you change the code to: new... more 9/6/2016 10:40:35 AM

people

Era in NodaTime

I noticed that of the date-related types -- LocalDate, LocalDateTime, OffsetDateTime, ZonedDateTime -- only LocalDate accepts era as a construction parameter: public...
Jon Skeet
people
quotationmark

A mixture of oversight and avoiding massive overloading, basically. It would certainly make logical sense to have such a constructor in LocalDateTime. ZonedDateTime and OffsetDateTime don't have constructors accepting individual... more 9/6/2016 6:48:16 AM

people

Correctly parse dates with timezones in Python

I am working from Europe and I have a series of datetime that look like these: datetime(2016,10,30,0,0,0) datetime(2016,10,30,1,0,0) datetime(2016,10,30,2,0,0) ...
Jon Skeet
people
quotationmark

This local value: datetime(2016,10,30,2,0,0) is ambiguous. 2am happens twice on October 30th 2016 in Berlin - once at 2016-10-30T00:00:00Z (with a UTC offset of +2), then once again at 2016-10-30T01:00:00Z (with a UTC offset of... more 9/5/2016 2:46:41 PM

people

How this Inner class inheritance example works?

I was reading about inheritance from inner classes and I got stuck trying to understand how the code below works: class Outer{ class Inner{ } } class Derived extends...
Jon Skeet
people
quotationmark

Suppose you have a variable o referring to an instance of Outer, and you want to create an instance of Inner with its enclosing instance being the value of o. You could call: Outer.Inner inner = o.new Outer.Inner(); It's rarely seen in... more 9/5/2016 11:57:24 AM

people

NodaTime get time offset

I have Xamarin PCL project and I added NuGet package "NodaTime". Especially I want to get difference of windows server time and my device time. Bu I couldn't find anything about...
Jon Skeet
people
quotationmark

Well Noda Time doesn't have any kind of server-based functionality - and even if it did, that would be likely to be NTP. Matt Johnson has a separate NodaTime.NetworkClock package, which is an IClock implementation for NTP. Now, does your... more 9/5/2016 6:00:25 AM

people

Why do I need to initialize an out variable when using Linq

Supposing I have a string which I want to convert to an integer, I would do int i; int.TryParse(someString, out i); Now I would like to do the same in a Linq query: int i; var...
Jon Skeet
people
quotationmark

The query expression is translated into: var numbers = someStrings.Where(s => int.TryParse(s, out i)) .Select(s => i); Now, we know that the delegate created from the lambda expression for the Where call... more 9/4/2016 3:28:03 PM

people

.NET CORE self contained application deployment. Why RID needs to be Known when .NET Core is cross platform

in a .NET Core self contained application ... We need to specify runtime (RIDs) in project.json we want our application to publish against... Why is that so? .NET Core is cross...
Jon Skeet
people
quotationmark

Precisely because it's self-contained... it contains the whole of .NET Core, or at least as much as is required to run your application. While .NET Core is cross-platform, that doesn't mean that you can use the Linux x64 CLR binary on a... more 9/3/2016 8:20:51 PM

people

IllegalMonitorStateException when sharing the object

I am trying to create single variable producer consumer solution , but I am getting IllegalMonitorStateException in Producer's notifyAll() method. I am acquiring the lock in...
Jon Skeet
people
quotationmark

This is the problem: synchronized(x) { x=10; x.notifyAll(); } It's important to understand that you don't synchronize on a variable - you synchronize on an object. So you're modify the value of x to refer to a different Integer... more 9/3/2016 12:41:51 PM

people