Quantcast

datenum does not understand num2str

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

datenum does not understand num2str

kamaraju
If this is a bug, I can file it. But just thought I will check here first as
it seems to be very basic.

Using octave 3.2.4 on Debian Wheezy

$octave -qf
octave:1> datenum('20120401', 'yyyymmdd')
ans =  734960
octave:2> datenum(num2str(20120401), 'yyyymmdd')
error: datevec: date not parsed correctly with given format
error: called from:
error:   /usr/share/octave/3.2.4/m/time/datevec.m at line 140, column 11
error:   /usr/share/octave/3.2.4/m/time/datenum.m at line 75, column 25
octave:2>

FWIW, the command works under matlab 7.9.1.671 (R2009b) Service Pack 1.

If I am guessing correctly, the format of the output from num2str cannot be
parsed correctly by datenum. Worth fixing or is there a work around?


thanks
--
Kamaraju S Kusumanchi
http://malayamaarutham.blogspot.com/

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: datenum does not understand num2str

Olafur Jens Sigurdsson-3
On Sun, Apr 01, 2012 at 07:52:20PM -0400, Kamaraju S Kusumanchi wrote:

> If this is a bug, I can file it. But just thought I will check here first as
> it seems to be very basic.
>
> Using octave 3.2.4 on Debian Wheezy
>
> $octave -qf
> octave:1> datenum('20120401', 'yyyymmdd')
> ans =  734960
> octave:2> datenum(num2str(20120401), 'yyyymmdd')
> error: datevec: date not parsed correctly with given format
> error: called from:
> error:   /usr/share/octave/3.2.4/m/time/datevec.m at line 140, column 11
> error:   /usr/share/octave/3.2.4/m/time/datenum.m at line 75, column 25
> octave:2>
>
> FWIW, the command works under matlab 7.9.1.671 (R2009b) Service Pack 1.
>
> If I am guessing correctly, the format of the output from num2str cannot be
> parsed correctly by datenum. Worth fixing or is there a work around?

datenum(num2str(20120104, 8), 'yyyymmdd')

Oli
_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: datenum does not understand num2str

kamaraju
Ólafur Jens Sigurðsson wrote:

> On Sun, Apr 01, 2012 at 07:52:20PM -0400, Kamaraju S Kusumanchi wrote:
>> If this is a bug, I can file it. But just thought I will check here first
>> as it seems to be very basic.
>>
>> Using octave 3.2.4 on Debian Wheezy
>>
>> $octave -qf
>> octave:1> datenum('20120401', 'yyyymmdd')
>> ans =  734960
>> octave:2> datenum(num2str(20120401), 'yyyymmdd')
>> error: datevec: date not parsed correctly with given format
>> error: called from:
>> error:   /usr/share/octave/3.2.4/m/time/datevec.m at line 140, column 11
>> error:   /usr/share/octave/3.2.4/m/time/datenum.m at line 75, column 25
>> octave:2>
>>
>> FWIW, the command works under matlab 7.9.1.671 (R2009b) Service Pack 1.
>>
>> If I am guessing correctly, the format of the output from num2str cannot
>> be parsed correctly by datenum. Worth fixing or is there a work around?
>
> datenum(num2str(20120104, 8), 'yyyymmdd')
>
> Oli

Thanks for the workaround. I reported this bug as
https://savannah.gnu.org/bugs/?36117 . Hopefully, someone will fix it.

--
Kamaraju S Kusumanchi
http://malayamaarutham.blogspot.com/

_______________________________________________
Help-octave mailing list
[hidden email]
https://mailman.cae.wisc.edu/listinfo/help-octave
Loading...