Creating date and time extension for tiddler time format and test.

This commit is contained in:
ruidajo 2022-10-06 15:39:00 -05:00
parent c827dfecd0
commit eca1e1ec05
2 changed files with 41 additions and 0 deletions

View File

@ -0,0 +1,28 @@
Extension { #name : #DateAndTime }
{ #category : #'*TiddlyWiki' }
DateAndTime >> asTiddlerFormat [
| hours minutes secondsTemp |
hours := self hours.
minutes := self minutes.
secondsTemp := self seconds.
^ (self dayMonthYearDo: [ :d :m :y |
y asString,
(m < 10
ifTrue: [ '0', m asString ]
ifFalse: [ m asString]),
(d < 10
ifTrue: [ '0', d asString ]
ifFalse: [ d asString])]),
(hours < 10
ifTrue: [ '0',hours asString ]
ifFalse: [ hours asString]),
(minutes < 10
ifTrue: [ '0', minutes asString ]
ifFalse: [ minutes asString]),
(secondsTemp < 10
ifTrue: [ '0', secondsTemp asString ]
ifFalse: [ secondsTemp asString]),
(self nanoSecond asString copyFrom: 1 to: 3)
]

View File

@ -0,0 +1,13 @@
Class {
#name : #TiddlerTest,
#superclass : #TestCase,
#category : #'TiddlyWiki-TiddlyWiki'
}
{ #category : #accessing }
TiddlerTest >> testTiddlerTimeFormatTrasnformation [
| tiddlerTemp |
tiddlerTemp := Tiddler new created: '20220101010101123'.
self assert: tiddlerTemp created equals: tiddlerTemp created asDateAndTimeForTiddler asTiddlerFormat
]