Browsing 7239 questions and answers with Jon Skeet

How can we convert a time from EDT to EST in rails?

I know the difference between EDT and EST is just in the Day Light Saving of 1 hour, but still I assume Rails treats it as different time zones, right? Now, I have two time...
Jon Skeet
people
quotationmark

I know the difference between EDT and EST is just in the Day Light Saving of 1 hour, but still I assume Rails treats it as different time zones, right? I wouldn't expect it to, no. They're not different time zones in themselves -... more 3/12/2015 7:04:14 AM

people

Can I Pass a return value of a getter method to a setter method of another object in a different class?

customer1.setExcursion1() = cust_dest.get_excursion1(); customer1 and cust_dest are two different objects from two different classes. Can I pass the return value of...
Jon Skeet
people
quotationmark

Yes, you can - but not like that. You call the setter method, passing in the value as an argument - you're currently trying to assign a value to the method call, which makes no sense. You... more 3/11/2015 7:18:47 PM

people

How to use array index without "Local variable x defined in an enclosing scope must be final..."

I'm writing a simple program, and there is one problem I cannot solve. I am creating textFields with such loop: testText = new JTextField[9][9]; for(int x = 0; x < 9;...
Jon Skeet
people
quotationmark

The best fix here is to simplify your code - remove all that duplication of testTest[x][y] by introducing a local variable which can be final (and thus allow you to use it within the anonymous inner class): testText = new... more 3/11/2015 5:40:47 PM

people

Xml C# i can't set a value for the element

XElement service = doc.Element("Ids"); service.Add(new XElement("ID", idulong.ToString(),new XElement("Succesfull",1))); Example...
Jon Skeet
people
quotationmark

Look at your code just changed to show the level of nesting: service.Add(new XElement("ID", idulong.ToString(), new XElement("Succesfull", 1))); In... more 3/11/2015 3:54:18 PM

people

Does "GMT Standard Time" imply BST?

I am confused by "GMT Standard Time". I have data which is stored as DATE only, but is actually 6PM BST. I read it in and add 18 hours. I then try to convert to UTC. My initial...
Jon Skeet
people
quotationmark

The problem is that the time zone IDs in Windows are confusing. Even though the ID is "GMT Standard Time", the time zone referred to by that ID is really "UK time"... like "Europe/London" in IANA. So yes, it will observe DST. If you want... more 3/11/2015 3:06:33 PM

people

Why to assign null before initialize object in C#

I'm following a tutorial on how to use capture video using the Windows MediaCapture API on Windows Phone and on the code examples, some of the variables are set to null just...
Jon Skeet
people
quotationmark

The only point in doing this would be if the MediaCaptureInitializationSettings constructor could throw an exception, and you wanted to make sure that in that case the variable didn't still have a reference to an "old" object. That's... more 3/11/2015 2:04:40 PM

people

More specific/stronger MemberExpression for compile time checking?

Consider the GetPropertyName method in the code sample below: using System; using System.Linq.Expressions; namespace SampleApp { public class Program { public...
Jon Skeet
people
quotationmark

Is there any way of making that method's parameter so specific that it wouldn't compile unless a get+set property is being passed? No. It's just a lambda expression. There are restrictions about what kind of lambda expressions can be... more 3/11/2015 10:17:47 AM

people

Convert Windows timezone to moment.js timezone?

We have an app in ASP.NET that stores all user timezone data in Windows format (by TimeZoneInfo.Id). We also use moment.js and moment.js TimeZone libraries to convert UTC data to...
Jon Skeet
people
quotationmark

TL;DR: Keep using Noda Time on the server side Choose whether to use BCL data or IANA data; I would personally recommend IANA, but it's your call. (Aside from anything else, IANA data is more clearly versioned.) Use Noda Time to generate... more 3/11/2015 8:38:15 AM

people

JAVA: how to download webpage dynamically created by servlet

I want to download a source of a webpage to a file (*.htm) (i.e. entire content with all html markups at all) from this URL:...
Jon Skeet
people
quotationmark

This isn't a servlet issue - that just happens to be the technology used to implement the server, but generally clients don't need to care about that. I strongly suspect it's just that the server is responding with different data depending... more 3/11/2015 7:23:37 AM

people

Linq Find Uncommon Items In 2 List(Of String)

Using VB.net I have two List(Of String) Here's how Im finding the common items between the two lists: Sub Main() Dim lstOne As New List(Of String)() _ ...
Jon Skeet
people
quotationmark

To stick within pure LINQ, you can use Except: Dim inOneNotTwo As IEnumerable(Of String) = lstOne.Except(lstNew) Dim inTwoNotOne As IEnumerable(Of String) = lstTwo.Except(lstNew) Alternatively, you could use HashSet(Of T) and... more 3/11/2015 7:04:58 AM

people