Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Made "First Brewed Date" in tree use user format. #121

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BtTreeItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ QVariant BtTreeItem::dataRecipe( int column )
break;
case RECIPEBREWDATECOL:
if ( recipe )
return QVariant(recipe->date());
return Brewtarget::displayDateUserFormated(recipe->date());
break;
case RECIPESTYLECOL:
if ( recipe && recipe->style() )
Expand Down
18 changes: 1 addition & 17 deletions src/brewnote.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -341,23 +341,7 @@ QDateTime BrewNote::fermentDate() const { return QDateTime::fromString(get("fe
QString BrewNote::fermentDate_str() const { return get("fermentDate").toString(); }
QString BrewNote::fermentDate_short() const { return fermentDate().toString("yyyy-MM-dd"); }
QString BrewNote::notes() const { return get("notes").toString(); }
QString BrewNote::brewDate_short() const
{
QString format;
switch (Brewtarget::getDateFormat())
{
case Unit::displayUS:
format = "MM-dd-yyyy";
break;
case Unit::displayImp:
format = "dd-MM-yyyy";
break;
default:
format = "yyyy-MM-dd";
}

return brewDate().toString(format);
}
QString BrewNote::brewDate_short() const { return Brewtarget::displayDateUserFormated(brewDate().date()); }

double BrewNote::sg() const { return get("sg").toDouble(); }
double BrewNote::abv() const { return get("abv").toDouble(); }
Expand Down
16 changes: 16 additions & 0 deletions src/brewtarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1387,6 +1387,22 @@ QString Brewtarget::displayDate(QDate const& date )
return date.toString(loc.dateFormat(QLocale::ShortFormat));
}

QString Brewtarget::displayDateUserFormated(QDate const &date) {
QString format;
switch (Brewtarget::getDateFormat()) {
case Unit::displayUS:
format = "MM-dd-yyyy";
break;
case Unit::displayImp:
format = "dd-MM-yyyy";
break;
default:
case Unit::displaySI:
format = "yyyy-MM-dd";
}
return date.toString(format);
}

bool Brewtarget::hasOption(QString attribute, const QString section, iUnitOps ops)
{
QString name;
Expand Down
2 changes: 2 additions & 0 deletions src/brewtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ class Brewtarget : public QObject

//! \brief Display date formatted for the locale.
static QString displayDate( QDate const& date );
//! \brief Display date formatted based on the user defined options.
static QString displayDateUserFormated(QDate const &date);
//! \brief Displays thickness in appropriate units from standard thickness in L/kg.
static QString displayThickness( double thick_lkg, bool showUnits=true );
//! \brief Appropriate thickness units will be placed in \c *volumeUnit and \c *weightUnit.
Expand Down