Creating date and time extension for tiddler time format and test.
This commit is contained in:
parent
c827dfecd0
commit
eca1e1ec05
28
repository/TiddlyWiki/DateAndTime.extension.st
Normal file
28
repository/TiddlyWiki/DateAndTime.extension.st
Normal 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)
|
||||||
|
]
|
13
repository/TiddlyWiki/TiddlerTest.class.st
Normal file
13
repository/TiddlyWiki/TiddlerTest.class.st
Normal 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
|
||||||
|
]
|
Loading…
Reference in New Issue
Block a user