1 /*
2  * Copyright (C) 2007 by Thorsten Staerk <dev@staerk.de>
3  * Copyright (C) 2019  Alexander Potashev <aspotashev@gmail.com>
4  *
5  *   This program is free software; you can redistribute it and/or modify
6  *   it under the terms of the GNU General Public License as published by
7  *   the Free Software Foundation; either version 2 of the License, or
8  *   (at your option) any later version.
9  *
10  *   This program is distributed in the hope that it will be useful,
11  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
12  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  *   GNU General Public License for more details.
14  *
15  *   You should have received a copy of the GNU General Public License along
16  *   with this program; if not, write to the
17  *      Free Software Foundation, Inc.
18  *      51 Franklin Street, Fifth Floor
19  *      Boston, MA  02110-1301  USA.
20  *
21  */
22 
23 #ifndef KTIMETRACKERUTILITY_H
24 #define KTIMETRACKERUTILITY_H
25 
26 #include <QString>
27 
28 #include <KCalendarCore/Incidence>
29 
30 /**
31   Format time for output.  All times output on screen or report output go
32   through this function.
33   If the second argument is true, the time is output as a two-place decimal.
34   Otherwise the format is hh:mi.
35   Examples:
36   30 seconds are 0.5 minutes.
37   The output of formatTiMe(0.5,true) is 0.008333, because 0.5 minutes are 0.008333 hours.
38   The output of formatTiMe(0.5,false) is 0:01, because 0.5 minutes are 0:01 hours rounded.
39  */
40 QString formatTime(double minutes, bool decimal = false);
41 
42 const int secsPerMinute = 60;
43 
44 enum KTIMETRACKER_Errors
45 {
46   KTIMETRACKER_ERR_GENERIC_SAVE_FAILED = 1,
47   KTIMETRACKER_ERR_COULD_NOT_MODIFY_RESOURCE,
48   KTIMETRACKER_ERR_MEMORY_EXHAUSTED,
49   KTIMETRACKER_ERR_UID_NOT_FOUND,
50   KTIMETRACKER_ERR_INVALID_DATE,
51   KTIMETRACKER_ERR_INVALID_TIME,
52   KTIMETRACKER_ERR_INVALID_DURATION,
53 
54   KTIMETRACKER_MAX_ERROR_NO = KTIMETRACKER_ERR_INVALID_DURATION
55 };
56 
57 QString getCustomProperty(const KCalendarCore::Incidence::Ptr &incident, const QString &name);
58 
59 #endif
60