This project has moved. For the latest updates, please go here.
1

Closed

DateTime an hour off

description

When datetime data types get converted to JSON they are off by an hour, specifically and hour behind. Not sure why this is done, but it is explicitly done in the JSON conversion. Seems like an error to me, as it breaks my charts.
Closed Jan 13, 2014 at 7:11 PM by zoranmax
I am closing this issue while there were no answer back and to my knowledge is not an issue.

comments

zoranmax wrote Nov 6, 2013 at 9:47 PM

Hi,
Can you post any example of the code you are using, so I can check if this can be reproduced?

Cheers,
Zoran

zoranmax wrote Nov 11, 2013 at 8:25 PM

Hi,
I couldn't reproduce the problem. As you can see in the code below, the result returned is correct.

Regards,
Zoran

using System;
using Google.DataTable.Net.Wrapper;

namespace ConsoleApplication1
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var now = DateTime.Now;

            Console.WriteLine("Current date and time: {0}", now);

            Console.WriteLine("--------------------------------");
            var json = ProduceJSON(now);

            Console.WriteLine(json);
            Console.Read();
        }

        public static string ProduceJSON(DateTime now)
        {
            //let's instantiate the DataTable.
            var dt = new Google.DataTable.Net.Wrapper.DataTable();
            dt.AddColumn(new Column(ColumnType.Datetime, "Date", "Date"));


            Row r = dt.NewRow();
            r.AddCellRange(new Cell[]
                {
                    new Cell(now)
                });
            dt.AddRow(r);

            //Let's create a Json string as expected by the Google Charts API.
            return dt.GetJson();
        }
    }
}
Output returned:
Current date and time: 11.11.2013 22:20:34
--------------------------------
{"cols": [{"type": "datetime" ,"id": "Date" ,"label": "Date" }], 
"rows" : [{"c" : [{"v": "Date(2013, 10, 11, 22, 20, 34)"}]}]}

wrote Jan 13, 2014 at 7:11 PM