Page MenuHomePhabricator

getHumanTimestamp() returns conjoined date + time from sprintfDate() for past years
Open, MediumPublic

Description

Language::getHumanTimestampInternal() contains the following:

		) {
			// Timestamps are in different years: use full timestamp
			// Also do full timestamp for future dates
			/**
			 * @todo FIXME: Add better handling of future timestamps.
			 */
			$format = $this->getDateFormatString( 'both', $user->getDatePreference() ?: 'default' );
			$ts = $this->sprintfDate( $format, $ts->getTimestamp( TS_MW ) );
		} elseif ( $days > 5 ) {
			// Timestamps are in same year,  but more than 5 days ago: show day and month only.
			$format = $this->getDateFormatString( 'pretty', $user->getDatePreference() ?: 'default' );
			$ts = $this->sprintfDate( $format, $ts->getTimestamp( TS_MW ) );

The second branch is perhaps acceptable because "pretty" means that only the date is returned; however the first isn't, because it just calls sprintfDate() and outputs a full timestamp, which is not suitable for lego messages (see T123545: Document expected lego usage of hours-ago, monday-at, yesterday-at and friends) and can cause problems when inserted in a sentence too. As far as I know sprintfDate() is only supposed to be used as a full sentence (or separate interface element), not for lego.

Date and time should be separated https://www.mediawiki.org/wiki/Localisation#Separate_times_from_dates_in_sentences ; I'm not sure if it would help to create new messages, to be used in this case by getHumanTimestamp() and where time and date would be passed separately.

Event Timeline

Nemo_bis raised the priority of this task from to Medium.
Nemo_bis updated the task description. (Show Details)
Nemo_bis added subscribers: Nemo_bis, Purodha.