@@ -35,9 +35,8 @@ extension NostrEventExtensions on NostrEvent {
3535 String ? get name => _getTagValue ('name' ) ?? 'Anon' ;
3636 String ? get geohash => _getTagValue ('g' );
3737 String ? get bond => _getTagValue ('bond' );
38- String ? get expiration => _timeAgo (_getTagValue ('expiration' ));
39- String ? timeAgoWithLocale (String ? locale) =>
40- _timeAgo (_getTagValue ('expiration' ), locale);
38+ String ? timeAgoWithLocale (String locale) =>
39+ _timeAgoFromCreated (locale);
4140 DateTime get expirationDate => _getTimeStamp (_getTagValue ('expiration' )! );
4241 String ? get expiresAt => _getTagValue ('expires_at' );
4342 String ? get platform => _getTagValue ('y' );
@@ -61,21 +60,10 @@ extension NostrEventExtensions on NostrEvent {
6160 .subtract (Duration (hours: 12 ));
6261 }
6362
64- String _timeAgo (String ? ts, [String ? locale]) {
65- if (ts == null ) return "invalid date" ;
66- final timestamp = int .tryParse (ts);
67- if (timestamp != null && timestamp > 0 ) {
68- final DateTime eventTime =
69- DateTime .fromMillisecondsSinceEpoch (timestamp * 1000 )
70- .subtract (Duration (hours: 48 ));
71-
72- // Use provided locale or fallback to Spanish
73- final effectiveLocale = locale ?? 'es' ;
74- return timeago.format (eventTime,
75- allowFromNow: true , locale: effectiveLocale);
76- } else {
77- return "invalid date" ;
78- }
63+
64+ String _timeAgoFromCreated (String locale) {
65+ if (createdAt == null ) return "invalid date" ;
66+ return timeago.format (createdAt! , allowFromNow: true , locale: locale);
7967 }
8068
8169 Future <NostrEvent > unWrap (String privateKey) async {
0 commit comments