help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: unix time in plot (an Octave problem?)


From: Vic Norton
Subject: Re: unix time in plot (an Octave problem?)
Date: Mon, 20 Jul 2015 15:39:07 -0400

On Jul 19, 2015, at 5:32 PM, Vic Norton <address@hidden> wrote:

> 
> On Jul 19, 2015, at 10:01 AM, Vic Norton <address@hidden> wrote:
> 
>> 
>> How do you format the x-axis for unixtime?
>> In gnuplot you might write
>> set xdata time
>> set timefmt "%s"
>> set format x "%Y-%m-%d"
>> How do you do this with the octave plot function?
> 
> Apparently you can't do it. No problem. I'll just set
> t = 0 <- 1420027200 ~ "2014-12-31 12:00:00 +0000"
> t = 1 <- 1451563200 ~ "2015-12-31 12:00:00 +0000"
> and work in the interval 0 <= t <= 1. Then it is be trivial
> to convert any unix time to the corresponding t, e.g.,
> 1435665600 ~ "2015-03-31 12:00:00 +0000" -> t = 0.246575.

But this exercise does show a possible deficiency in Octave.
I put the unix times above in the following Octave script:
 printf("This looks right. It's what I want.\n");
 printf("  %s\n", strftime("%Y-%m-%d %X %Z", gmtime(1420027200)));
 printf("  %s\n", strftime("%Y-%m-%d %X %Z", gmtime(1435665600)));
 printf("  %s\n", strftime("%Y-%m-%d %X %Z", gmtime(1451563200)));
 printf("But shouldn't all the %%z time zones read +0000?\n");
 printf("  %s\n", strftime("%Y-%m-%d %X %z", gmtime(1420027200)));
 printf("  %s\n", strftime("%Y-%m-%d %X %z", gmtime(1435665600)));
 printf("  %s\n", strftime("%Y-%m-%d %X %z", gmtime(1451563200)));
The results are a bit disturbing:
 This looks right. It's what I want.
   2014-12-31 12:00:00 UTC
   2015-06-30 12:00:00 UTC
   2015-12-31 12:00:00 UTC
 But shouldn't all the %z time zones read +0000?
   2014-12-31 12:00:00 -48038628
   2015-06-30 12:00:00 -48040837
   2015-12-31 12:00:00 -48053659
See, for example,
http://search.cpan.org/~dexter/POSIX-strftime-GNU-0.0301/lib/POSIX/strftime/GNU.pm

Regards,

Vic

P.S. now I realize that there was an error in my second
message. It should have read
 1435665600 ~ "2015-06-30 12:00:00 +0000" -> t = 0.495890.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]