[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Can't define methods on a @datetime class
From: |
Andrew Janke |
Subject: |
Can't define methods on a @datetime class |
Date: |
Sat, 12 Jan 2019 02:23:33 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 |
Hi, Octave maintainers,
I'm working on an experimental implementation of the @datetime class.
I have a basic class that defines properties and basic conversions:
https://github.com/apjanke/octave-addons/blob/968429c90ac25a422dec70bdd3c25811faba92ce/Mcode/datetime.m
I'm able to construct @datetime objects. And I can access its properties
to verify it was constructed correctly.
But I'm not able to call any methods on them. Octave is not recognizing
that they're defined.
For example, I've defined a custom disp() for it, but the output remains
the default "<object datetime>". And I
have a datestr() method, but attempting to call it looks like it's
calling the default datestr function. I have a hello()
method, and that seems to work, so it's at least picking up some of the
definitions. But "methods(d)" reports
no methods.
Could Octave's built-in "unimplemented" placeholder function for
datetime be interfering with my ability to define
a class named "datetime"?
Example:
octave:1> cd ~/local/repos/octave-addons/Mcode; addpath
~/local/repos/octave-addons/Mcode
octave:2> d = datetime('now')
d =
<object datetime>
octave:3> d.dnums
ans = 737437.0985309570
octave:4> datestr(d.dnums)
ans = 12-Jan-2019 02:21:53
octave:5> datestr(d)
error: floor: not defined for object
error: called from
datevec at line 161 column 7
datestr at line 181 column 7
octave:5> hello(d)
ans = Hello, world!
octave:6> methods(d)
Methods for class datetime:
octave:7> class(d)
ans = datetime
octave:8> which datetime
'datetime' is a built-in function
octave:9>
Cheers,
Andrew
- Can't define methods on a @datetime class,
Andrew Janke <=
- Re: Can't define methods on a @datetime class, Andreas Weber, 2019/01/12
- Re: Can't define methods on a @datetime class, Andrew Janke, 2019/01/12
- Re: Can't define methods on a @datetime class, Andreas Weber, 2019/01/12
- Re: Can't define methods on a @datetime class, Andrew Janke, 2019/01/12
- Re: Can't define methods on a @datetime class, Andreas Weber, 2019/01/13
- Re: Can't define methods on a @datetime class, Andrew Janke, 2019/01/13
- Re: Can't define methods on a @datetime class, Andrew Janke, 2019/01/17
Re: Can't define methods on a @datetime class, Mike Miller, 2019/01/12