calendar/base/backend/libical/calDateTime.h
author Pike <l10n@mozilla.com> and Richard Marti <richard.marti@gmail.com> and Jorg K <jorgk@jorgk.com>
Fri, 17 Feb 2017 17:05:49 +0100
changeset 27653 6ee27a7af6cd3e7bd25f392048fd40160910275a
parent 22170 bc959dd6181feacd1775cc6f14cb3c9338c7f847
child 34313 800083958fbff28505e21949e35db34901c9d71d
permissions -rw-r--r--
Bug 1322402 - Drop support for universal Mac builds. rs=bustage-fix

/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#if !defined(INCLUDED_CALDATETIME_H)
#define INCLUDED_CALDATETIME_H

#include "calIDateTime.h"
#include "calITimezoneProvider.h"
#include "calUtils.h"

struct icaltimetype;
typedef struct _icaltimezone icaltimezone;

class calDateTime : public calIDateTimeLibical,
                    public cal::XpcomBase
{
public:
    calDateTime();
    calDateTime(icaltimetype const* icalt, calITimezone * tz);

    NS_DECL_ISUPPORTS
    NS_DECL_CALIDATETIME
    NS_DECL_CALIDATETIMELIBICAL

protected:
    virtual ~calDateTime() {}
    bool mImmutable;
    bool mIsValid;
    bool mIsDate;

    int16_t mYear;
    int16_t mMonth;
    int16_t mDay;
    int16_t mHour;
    int16_t mMinute;
    int16_t mSecond;
    int16_t mWeekday;
    int16_t mYearday;

    PRTime mNativeTime;
    nsCOMPtr<calITimezone> mTimezone;

    void Normalize();
    void FromIcalTime(icaltimetype const* icalt, calITimezone *tz);
    void ensureTimezone();

    static PRTime IcaltimeToPRTime(icaltimetype const* icalt, icaltimezone const* tz);
    static void PRTimeToIcaltime(PRTime time, bool isdate,
                                 icaltimezone const* tz, icaltimetype *icalt);
};

#endif // INCLUDED_CALDATETIME_H