A while back, I decided to work with floating point Julian dates instead of DateTime objects, but now that I think about it, that was mostly for my convenience, and it may be time to revisit that decision.
In any case, I am still curious about the questions I posed. Could you expand a bit about inheriting from types? How would that differ from my type definition? Thanks, Chris On Monday, March 16, 2015 at 4:19:02 PM UTC-4, tshort wrote: > > Can you just use the DateTime type in Julia? > > http://julia.readthedocs.org/en/latest/stdlib/dates/ > > This is in the development version of Julia. For a backwards-compatible > implementation for Julia 0.3, see: > > https://github.com/quinnj/Dates.jl > > If the DateTime type isn't suitable (for example, millisecond resolution), > you could possibly inherit from suitable types and still get more features > than you currently have. > > > > On Mon, Mar 16, 2015 at 4:00 PM, Chris <7hunde...@gmail.com <javascript:>> > wrote: > >> Hello, >> >> I have written a bunch of Julia code with functions assuming a certain >> variable (time) is a Float64 (really it's a Julian Date). I recently >> decided it might be a good idea to introduce a custom JDate type, which >> I defined as a subtype of FloatingPoint: >> >> immutable JDate <: FloatingPoint >> >> t::Float64 >> >> end >> >> >> My thinking being that this would help avoid ambiguity with my code, as >> I sometimes work with other units of time (e.g. seconds) that are also >> floating point numbers. Of course, this introduced a number of problems in >> my existing code, including >> >> 1. Arithmetic operators not defined for type JDate. My workaround for >> this has thus far been to overload the operators to accept JDate >> types. >> 2. My functions not having methods that accept time as a JDate type. >> My workaround for this has been to change the function to accept >> time::FloatingPoint >> instead of time::Float64, but this workaround does not work for >> Arrays. >> >> I've read through the relevant parts of the documentation, although I'm >> not sure how much actually stuck, since a good portion was over my head. >> >> In general, am I going about this the right way? If not, what should I do >> differently? Is there any way to resolve the issue with Arrays, besides >> creating another method that accepts Array{JDate,1}? >> >> Thanks in advance, >> Chris >> > >