mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-04 22:40:29 +03:00
Document functions
This commit is contained in:
parent
2a368d46fc
commit
591c6b9430
2 changed files with 24 additions and 0 deletions
|
|
@ -4,6 +4,18 @@ import PropTypes from 'prop-types';
|
|||
import dateFormat from 'dateformat';
|
||||
import { isInSameDay } from '../../../util/common';
|
||||
|
||||
/**
|
||||
* Renders a formatted timestamp.
|
||||
*
|
||||
* Displays the time in hour:minute format if the message is from today or yesterday, unless `fullTime` is true.
|
||||
* For older messages, it shows the date and time.
|
||||
*
|
||||
* @param {number} timestamp - The timestamp to display.
|
||||
* @param {boolean} [fullTime=false] - If true, always show the full date and time.
|
||||
* @param {boolean} hour24Clock - Whether to use 24-hour time format.
|
||||
* @param {string} dateFormatString - Format string for the date part.
|
||||
* @returns {JSX.Element} A <time> element with the formatted date/time.
|
||||
*/
|
||||
function Time({ timestamp, fullTime, hour24Clock, dateFormatString }) {
|
||||
const date = new Date(timestamp);
|
||||
|
||||
|
|
|
|||
|
|
@ -9,6 +9,18 @@ export type TimeProps = {
|
|||
dateFormatString: string;
|
||||
};
|
||||
|
||||
/**
|
||||
* Renders a formatted timestamp, supporting compact and full display modes.
|
||||
*
|
||||
* Displays the time in hour:minute format if the message is from today, yesterday, or if `compact` is true.
|
||||
* For older messages, it shows the date and time.
|
||||
*
|
||||
* @param {number} ts - The timestamp to display.
|
||||
* @param {boolean} [compact=false] - If true, always show only the time.
|
||||
* @param {boolean} hour24Clock - Whether to use 24-hour time format.
|
||||
* @param {string} dateFormatString - Format string for the date part.
|
||||
* @returns {React.ReactElement} A <Text as="time"> element with the formatted date/time.
|
||||
*/
|
||||
export const Time = as<'span', TimeProps & ComponentProps<typeof Text>>(
|
||||
({ compact, hour24Clock, dateFormatString, ts, ...props }, ref) => {
|
||||
const formattedTime = timeHourMinute(ts, hour24Clock);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue