From c14e40152ea01bde6af2fb9fdbe43af49522b02e Mon Sep 17 00:00:00 2001 From: ruidajo Date: Tue, 12 Jul 2022 10:35:43 -0500 Subject: [PATCH] Creating Date and time from tiddler date string and parsing oldest created tiddler. --- repository/TiddlyWiki/String.extension.st | 22 ++++++++++++++++++++++ repository/TiddlyWiki/TiddlyWiki.class.st | 9 +++++++++ 2 files changed, 31 insertions(+) create mode 100644 repository/TiddlyWiki/String.extension.st diff --git a/repository/TiddlyWiki/String.extension.st b/repository/TiddlyWiki/String.extension.st new file mode 100644 index 0000000..502fde6 --- /dev/null +++ b/repository/TiddlyWiki/String.extension.st @@ -0,0 +1,22 @@ +Extension { #name : #String } + +{ #category : #'*TiddlyWiki' } +String >> asDateAndTimeForTiddler [ + + | date | + date := OrderedCollection new. + 1 to: 4 do: [ :i | date add: (self at: i) ]. + date add: '-'. + 5 to: 6 do: [ :i | date add: (self at: i) ]. + date add: '-'. + 7 to: 8 do: [ :i | date add: (self at: i) ]. + date add: 'T'. + 9 to: 10 do: [ :i | date add: (self at: i) ]. + date add: ':'. + 11 to: 12 do: [ :i | date add: (self at: i) ]. + date add: ':'. + 13 to: 14 do: [ :i | date add: (self at: i) ]. + date add: '.'. + 15 to: 17 do: [ :i | date add: (self at: i) ]. + ^ (date joinUsing: '') asDateAndTime +] diff --git a/repository/TiddlyWiki/TiddlyWiki.class.st b/repository/TiddlyWiki/TiddlyWiki.class.st index 692afe3..ef3b662 100644 --- a/repository/TiddlyWiki/TiddlyWiki.class.st +++ b/repository/TiddlyWiki/TiddlyWiki.class.st @@ -436,6 +436,15 @@ TiddlyWiki >> networkView [ ^ view ] +{ #category : #accessing } +TiddlyWiki >> oldestCreatedTiddler [ + + | tiddlersTemp oldestDate | + tiddlersTemp := self tiddlers. + oldestDate := (tiddlersTemp collect: [ :tiddler | tiddler created asDateAndTimeForTiddler ]) asSortedCollection first. + ^ (tiddlersTemp select:[ :tiddler | tiddler created asDateAndTimeForTiddler = oldestDate ]) first. +] + { #category : #accessing } TiddlyWiki >> printOn: aStream [ super printOn: aStream.