Remove full date format from Tracker date columns
It is too similar to the long format and does not add much value. And it creates some problems with using a locale format with another's string. Fixes #11343.
This commit is contained in:
parent
1416521f10
commit
0597752447
@ -52,6 +52,7 @@ All rights reserved.
|
|||||||
#include <MessageFormat.h>
|
#include <MessageFormat.h>
|
||||||
#include <NodeInfo.h>
|
#include <NodeInfo.h>
|
||||||
#include <Path.h>
|
#include <Path.h>
|
||||||
|
#include <SupportDefs.h>
|
||||||
#include <TextView.h>
|
#include <TextView.h>
|
||||||
#include <Volume.h>
|
#include <Volume.h>
|
||||||
#include <VolumeRoster.h>
|
#include <VolumeRoster.h>
|
||||||
@ -198,11 +199,11 @@ TruncTimeBase(BString* outString, int64 value, const View* view, float width)
|
|||||||
|
|
||||||
time_t timeValue = (time_t)value;
|
time_t timeValue = (time_t)value;
|
||||||
|
|
||||||
|
// Find the longest possible format that will fit the available space
|
||||||
struct {
|
struct {
|
||||||
BDateFormatStyle dateStyle;
|
BDateFormatStyle dateStyle;
|
||||||
BTimeFormatStyle timeStyle;
|
BTimeFormatStyle timeStyle;
|
||||||
} formats[5] = {
|
} formats[] = {
|
||||||
{ B_FULL_DATE_FORMAT, B_MEDIUM_TIME_FORMAT },
|
|
||||||
{ B_LONG_DATE_FORMAT, B_MEDIUM_TIME_FORMAT },
|
{ B_LONG_DATE_FORMAT, B_MEDIUM_TIME_FORMAT },
|
||||||
{ B_LONG_DATE_FORMAT, B_SHORT_TIME_FORMAT },
|
{ B_LONG_DATE_FORMAT, B_SHORT_TIME_FORMAT },
|
||||||
{ B_MEDIUM_DATE_FORMAT, B_SHORT_TIME_FORMAT },
|
{ B_MEDIUM_DATE_FORMAT, B_SHORT_TIME_FORMAT },
|
||||||
@ -211,13 +212,19 @@ TruncTimeBase(BString* outString, int64 value, const View* view, float width)
|
|||||||
|
|
||||||
BString date;
|
BString date;
|
||||||
BDateTimeFormat formatter;
|
BDateTimeFormat formatter;
|
||||||
for (int i = 0; resultWidth > width && i < 5; ++i) {
|
for (unsigned int i = 0; i < B_COUNT_OF(formats); ++i) {
|
||||||
if (formatter.Format(date, timeValue, formats[i].dateStyle,
|
if (formatter.Format(date, timeValue, formats[i].dateStyle,
|
||||||
formats[i].timeStyle) == B_OK) {
|
formats[i].timeStyle) == B_OK) {
|
||||||
resultWidth = view->StringWidth(date.String(), date.Length());
|
resultWidth = view->StringWidth(date.String(), date.Length());
|
||||||
|
if (resultWidth <= width) {
|
||||||
|
// Found a format that fits the available space, stop searching
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If we couldn't fit the date, try with just the time
|
||||||
|
// TODO we could use only the time for "today" dates
|
||||||
if (resultWidth > width
|
if (resultWidth > width
|
||||||
&& BDateFormat().Format(date, timeValue,
|
&& BDateFormat().Format(date, timeValue,
|
||||||
B_SHORT_DATE_FORMAT) == B_OK) {
|
B_SHORT_DATE_FORMAT) == B_OK) {
|
||||||
|
Loading…
Reference in New Issue
Block a user