haiku/headers/os/locale/RelativeDateTimeFormat.h
Akshay Agarwal 1e4ab34cd7 Implement a formatter for relative dates.
Signed-off-by: Adrien Destugues <pulkomandy@pulkomandy.tk>

It can give results such as "in 2 hours", "2 days ago", etc.
This is different from BDurationFormat which will just say "1 hour, 2
minute and 36 seconds"
2017-08-25 21:14:27 +02:00

45 lines
1.0 KiB
C++

/*
* Copyright 2017, Haiku, Inc. All Rights Reserved.
* Distributed under the terms of the MIT License.
*
* Authors:
* Akshay Agarwal <agarwal.akshay.akshay8@gmail.com>
*/
#ifndef _B_RELATIVE_DATE_TIME_FORMAT_H_
#define _B_RELATIVE_DATE_TIME_FORMAT_H_
#include <Format.h>
#include <SupportDefs.h>
class BString;
#ifndef U_ICU_NAMESPACE
#define U_ICU_NAMESPACE icu
#endif
namespace U_ICU_NAMESPACE {
class GregorianCalendar;
class RelativeDateTimeFormatter;
}
class BRelativeDateTimeFormat: public BFormat {
typedef BFormat Inherited;
public:
BRelativeDateTimeFormat();
BRelativeDateTimeFormat(const BLanguage& language,
const BFormattingConventions& conventions);
BRelativeDateTimeFormat(const BRelativeDateTimeFormat& other);
virtual ~BRelativeDateTimeFormat();
status_t Format(BString& string, const time_t timeValue) const;
private:
U_ICU_NAMESPACE::RelativeDateTimeFormatter* fFormatter;
U_ICU_NAMESPACE::GregorianCalendar* fCalendar;
};
#endif // _B_RELATIVE_DATE_TIME_FORMAT_H_