Lucene++ - a full-featured, c++ search engine
API Documentation

Loading...
Searching...
No Matches
DateTools.h
Go to the documentation of this file.
1
2// Copyright (c) 2009-2014 Alan Wright. All rights reserved.
3// Distributable under the terms of either the Apache License (Version 2.0)
4// or the GNU Lesser General Public License.
6
7#ifndef DATETOOLS_H
8#define DATETOOLS_H
9
10#include "LuceneObject.h"
11
12 namespace Lucene {
13
28 class LPPAPI DateTools : public LuceneObject {
29 public:
30 virtual ~DateTools();
31
32 LUCENE_CLASS(DateTools);
33
34 public:
35 enum Resolution {
36 RESOLUTION_NULL,
37 RESOLUTION_YEAR,
38 RESOLUTION_MONTH,
39 RESOLUTION_DAY,
40 RESOLUTION_HOUR,
41 RESOLUTION_MINUTE,
42 RESOLUTION_SECOND,
43 RESOLUTION_MILLISECOND
44 };
45
46 enum DateOrder {
47 DATEORDER_LOCALE,
48 DATEORDER_YMD,
49 DATEORDER_DMY,
50 DATEORDER_MDY
51 };
52
53 protected:
54 static DateOrder dateOrder;
55
56 public:
61 static String dateToString(const boost::posix_time::ptime& date, Resolution resolution);
62
67 static String timeToString(int64_t time, Resolution resolution);
68
73 static int64_t stringToTime(const String& dateString);
74
78 static boost::posix_time::ptime stringToDate(const String& dateString);
79
84 static boost::posix_time::ptime round(const boost::posix_time::ptime& date, Resolution resolution);
85
91 static int64_t round(int64_t time, Resolution resolution);
92
94 static void setDateOrder(DateTools::DateOrder order);
95
97 static DateTools::DateOrder getDateOrder(std::locale locale = std::locale());
98
103 static boost::posix_time::ptime parseDate(const String& dateString, std::locale locale = std::locale());
104};
105
106}
107
108#endif
LuceneObject.h
LUCENE_CLASS
#define LUCENE_CLASS(Name)
Definition LuceneObject.h:24
Lucene::DateTools
Provides support for converting dates to strings and vice-versa. The strings are structured so that l...
Definition DateTools.h:28
Lucene::DateTools::stringToDate
static boost::posix_time::ptime stringToDate(const String &dateString)
Converts a string produced by timeToString or dateToString back to a time, represented as a ptime obj...
Lucene::DateTools::round
static int64_t round(int64_t time, Resolution resolution)
Limit a date's resolution. For example, the date 1095767411000 (which represents 2004-09-21 13:50:11)...
Lucene::DateTools::setDateOrder
static void setDateOrder(DateTools::DateOrder order)
Allow overriding of date ordering.
Lucene::DateTools::~DateTools
virtual ~DateTools()
Lucene::DateTools::getDateOrder
static DateTools::DateOrder getDateOrder(std::locale locale=std::locale())
Return date ordering based on given locale (or overridden in setDateOrder(DateTools::DateOrder)).
Lucene::DateTools::dateOrder
static DateOrder dateOrder
Definition DateTools.h:54
Lucene::DateTools::Resolution
Resolution
Definition DateTools.h:35
Lucene::DateTools::RESOLUTION_MONTH
@ RESOLUTION_MONTH
Definition DateTools.h:38
Lucene::DateTools::RESOLUTION_SECOND
@ RESOLUTION_SECOND
Definition DateTools.h:42
Lucene::DateTools::RESOLUTION_YEAR
@ RESOLUTION_YEAR
Definition DateTools.h:37
Lucene::DateTools::RESOLUTION_MINUTE
@ RESOLUTION_MINUTE
Definition DateTools.h:41
Lucene::DateTools::RESOLUTION_DAY
@ RESOLUTION_DAY
Definition DateTools.h:39
Lucene::DateTools::RESOLUTION_HOUR
@ RESOLUTION_HOUR
Definition DateTools.h:40
Lucene::DateTools::RESOLUTION_NULL
@ RESOLUTION_NULL
Definition DateTools.h:36
Lucene::DateTools::parseDate
static boost::posix_time::ptime parseDate(const String &dateString, std::locale locale=std::locale())
Parse a given date using locale date format.
Lucene::DateTools::round
static boost::posix_time::ptime round(const boost::posix_time::ptime &date, Resolution resolution)
Limit a date's resolution. For example, the date 2004-09-21 13:50:11 will be changed to 2004-09-01 00...
Lucene::DateTools::stringToTime
static int64_t stringToTime(const String &dateString)
Converts a string produced by timeToString or dateToString back to a time, represented as the number ...
Lucene::DateTools::timeToString
static String timeToString(int64_t time, Resolution resolution)
Converts a millisecond time to a string suitable for indexing.
Lucene::DateTools::dateToString
static String dateToString(const boost::posix_time::ptime &date, Resolution resolution)
Converts a Date to a string suitable for indexing.
Lucene::DateTools::DateOrder
DateOrder
Definition DateTools.h:46
Lucene::DateTools::DATEORDER_DMY
@ DATEORDER_DMY
Definition DateTools.h:49
Lucene::DateTools::DATEORDER_LOCALE
@ DATEORDER_LOCALE
Definition DateTools.h:47
Lucene::DateTools::DATEORDER_YMD
@ DATEORDER_YMD
Definition DateTools.h:48
Lucene::LuceneObject
Base class for all Lucene classes.
Definition LuceneObject.h:31
Lucene
Definition AbstractAllTermDocs.h:12

clucene.sourceforge.net