-
Notifications
You must be signed in to change notification settings - Fork 447
Open
Description
💡 Proposed Feature
Add a helper function like the following to the DateTimeLib library to convert a UNIX timestamp into a human-readable ISO 8601-style string.
I'm a bit conflicted raising this, as it's very client specific to format or use the return date variables however they want, and this lib produces the data to do so. But on the other hand, for these 'one liner string return helpers' I would think this would be a common enough usecase for helper code to not be in client specific contracts and be inside the lib itself.
function formatDateTime(uint256 timestamp) external pure returns (string memory) {
(
uint256 year,
uint256 month,
uint256 day,
uint256 hour,
uint256 minute,
uint256 second
) = DateTimeLib.timestampToDateTime(timestamp);
return
string.concat(
_toString(year),
"-",
_toString(month),
"-",
_toString(day),
" ",
_toString(hour),
":",
_toString(minute),
":",
_toString(second),
" UTC"
);
}Metadata
Metadata
Assignees
Labels
No labels