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

Add new converter methods #160

Merged
merged 2 commits into from
Mar 22, 2023
Merged
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
30 changes: 27 additions & 3 deletions src/Converter.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public function toFormattedDateString()
*
* @return string
*/
public function toFormattedDayDateString(): string
public function toFormattedDayDateString()
{
return $this->format('l j F Y');
}
Expand Down Expand Up @@ -68,6 +68,18 @@ public function toDateTimeString($unitPrecision = 'second')
return $this->format('Y/m/d ' . static::getTimeFormatByPrecision($unitPrecision));
}

/**
* Format the instance as a readable date and time
*
* @param string $unitPrecision
*
* @return string
*/
public function toFormattedDateTimeString($unitPrecision = 'second')
{
return $this->format('j F Y ' . static::getTimeFormatByPrecision($unitPrecision));
}

/**
* Return a format from H:i to H:i:s.u according to given unit precision.
*
Expand Down Expand Up @@ -110,11 +122,23 @@ public function toDateTimeLocalString($unitPrecision = 'second')
/**
* Format the instance with day, date and time
*
* @param string $unitPrecision
*
* @return string
*/
public function toDayDateTimeString($unitPrecision = 'second')
{
return $this->format('l j F Y ' . static::getTimeFormatByPrecision($unitPrecision));
}

/**
* Format the instance with the year, and a readable month
*
* @return string
*/
public function toDayDateTimeString()
public function toFormattedMonthYearString()
{
return $this->format('l j F Y g:i A');
return $this->format('F Y');
}
morilog marked this conversation as resolved.
Show resolved Hide resolved

}