[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-pim
Subject:    Re: [Kde-pim] Say hello and a proposal...
From:       Rik Hemsley <rik () kde ! org>
Date:       2002-02-25 13:39:56
[Download RAW message or body]

#if Adriaan de Groot
> On Mon, 25 Feb 2002, Rik Hemsley wrote:
> > How many calendar types are in use in the world ? If there are only 2
> > or 3, perhaps it would be easiest to simply provide conversions, rather
> > than using an abstract calendar and deriving from it ?
> 
> Thing is, eventually someone is going to want a Klingon calendar, or a
> Mayan one, and I can think of five calendar schema's relevant right now:
> 
> - Gregorian
> - Julian
> - Hijri (moon-based)
> - Jewish (moon-based)
> - Chinese (?)
> 
> I vaguely recall the Mormons and Russian Orthodox churches having peculiar
> calendars as well. And this list only includes northern-hemisphere
> calendars.

Ok, well, this will be fun then :)

> This suggests that explicit coversions will cause a tangle later, and that
> a single universal base class is a better choice (64-bit signed time_t
> offset from 1970, anyone?). Then you can have:

Sounds like TAI to me. I use this class for some personal stuff...

class TAI
{
  public:

    TAI(u_int64_t sec = 0)
      : sec_(sec)
    {
    }

    double approx()
    {
      return double(sec_);
    }

    u_int64_t sec() const
    {
      return sec_;
    }

    TAI & setSec(u_int64_t sec)
    {
      sec_ = sec;
      return *this;
    }

    bool operator == (const TAI & other) const
    {
      return sec_ == other.sec_;
    }

    TAI & operator += (const TAI & other)
    {
      sec_ += other.sec_;
      return *this;
    }

    TAI & operator -= (const TAI & other)
    {
      sec_ -= other.sec_;
      return *this;
    }

    static TAI now()
    {
      return TAI(4611686018427387914ULL + u_int64_t(::time(0)));
    }

    bool operator < (const TAI & other)
    {
      return sec_ < other.sec_;
    }

  private:

    u_int64_t sec_;
};

I also have a TAIA class, which uses 64 bits for seconds, 32 for
nanoseconds and 32 for attoseconds. Probably overkill :)
 
> > I'm no date guru :)
> 
> Show me *any* geek who knows what to do with a date, eh.

/me looks at QTimeEdit, which doesn't allow negative times :/

Rik

_______________________________________________
kde-pim mailing list
kde-pim@mail.kde.org
http://mail.kde.org/mailman/listinfo/kde-pim
kde-pim home page at http://pim.kde.org/
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic