aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/renderer/MCDateFormatter.h
blob: 4a789b1dd1f4157734a52606b1e6df878fedc32c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//
//  MCDateFormatter.h
//  testUI
//
//  Created by DINH Viêt Hoà on 1/28/13.
//  Copyright (c) 2013 MailCore. All rights reserved.
//

#ifndef MAILCORE_MCDATEFORMATTER_H

#define MAILCORE_MCDATEFORMATTER_H

#include <MailCore/MCBaseTypes.h>

// predeclare UDateFormat
// copied from <unicode/udat.h>
typedef void * UDateFormat;

#ifdef __cplusplus

namespace mailcore {
    
    class String;
    
    // Uses same values as UDateFormatStyle
    enum DateFormatStyle {
        DateFormatStyleFull = 0 /* UDAT_FULL*/,
        DateFormatStyleLong = 1 /* UDAT_LONG */,
        DateFormatStyleMedium = 2 /* UDAT_MEDIUM */,
        DateFormatStyleShort = 3 /* UDAT_SHORT */,
        DateFormatStyleNone = -1 /* UDAT_NONE */,
    };
    
    class MAILCORE_EXPORT DateFormatter : public Object {
    public:
        DateFormatter();
        virtual ~DateFormatter();
        
        static DateFormatter * dateFormatter();
        
        virtual void prepare();

        virtual void setDateStyle(DateFormatStyle style);
        virtual DateFormatStyle dateStyle();
        
        virtual void setTimeStyle(DateFormatStyle style);
        virtual DateFormatStyle timeStyle();
        
        virtual void setLocale(String * locale);
        virtual String * locale();
        
        virtual void setTimezone(String * timezone);
        virtual String * timezone();
        
        virtual void setDateFormat(String * dateFormat);
        virtual String * dateFormat();
        
        virtual String * stringFromDate(time_t date);
        virtual time_t dateFromString(String * dateString);

    private:
        UDateFormat * mDateFormatter;
        DateFormatStyle mDateStyle;
        DateFormatStyle mTimeStyle;
        String * mDateFormat;
        String * mTimezone;
        String * mLocale;
        void * mAppleDateFormatter;
    };
    
}

#endif

#endif /* defined(__testUI__MCDateFormatter__) */