1
$\begingroup$

I am importing TimeSeries data from an external CSV file. Those CSV date/time values are implicitly expressed as UTC. But TimeSeries imports them using \$TimeZone. And although TimeSeriesShift allows me to "realign" the events to ( - \$TimeZone) , Mathematica still presents time values with an offset of \$TimeZone.

How might I implement an option for TimeSeries[...] along the lines of TimeZone -> 0?

$\endgroup$
1
  • $\begingroup$ Perhaps Block[{$TimeZone = 0}, TimeSeries[ ...]]? $\endgroup$
    – Somos
    Commented Apr 26, 2019 at 16:49

3 Answers 3

1
$\begingroup$

Specify both DateFunction and TimeZone upon import and creation of TimeSeries.

$\endgroup$
1
  • $\begingroup$ Gosia -- thank you! $\endgroup$ Commented Aug 3, 2019 at 19:52
1
$\begingroup$

Sample data is always helpful.

One idea is to use the DateFunction option. Here is some made up data:

data = {{"10pm jan 1",1}, {"11pm jan 1", 2}, {"1am jan 2", 3}};

Default behavior using TimeSeries:

DateListPlot @ TimeSeries[data]

enter image description here

Using the option DateFunction to adjust the TimeZone:

DateListPlot @ TimeSeries[data, DateFunction -> (DateList[#, TimeZone->0]&)]

enter image description here

$\endgroup$
0
$\begingroup$

OBJECTIVE: The following string-valued timestamps are to be imported as UTC TimeZone values

csvImport = {{"1968-01-01 00:00", 100}, {"1968-01-01 00:01", 200}};

The following results in a corrupted time value of "1968-01-01 00:00 GMT-5"

TimeSeries[csvImport]["FirstDate"]

The following yields correct timevalues and TimeZone, but does not work in my production WLS script

Block[{$TimeZone}, 
$TimeZone = 0;
TimeSeries[csvImport]["FirstDate"]]

The following are correct timevalues but wrong displayed TimeZone

altCVSImport = csvImport;
altCVSImport[[All, 1]] = DateObject[#, TimeZone -> 0] & /@ altCVSImport[[All, 1]];
TimeSeries[altCVSImport]["FirstDate"]

The following tweak displays correct timevalue and TimeZone

TimeSeries[altCVSImport, "TimeZone" -> 0]["FirstDate"]
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.