Explaining rationale and pros/cons behind encoding approach.
This commit is contained in:
parent
547bba2c14
commit
c984b4768d
@ -126,14 +126,19 @@ Tiddler >> createdAsTWFormat [
|
||||
]
|
||||
|
||||
{ #category : #accessing }
|
||||
Tiddler >> createdEncoded [
|
||||
Tiddler >> createdReversableEncoded [
|
||||
"I encode the tiddler creation date with miliseconds precision in a shorter reversable way
|
||||
(from 17 characters to 10).
|
||||
But when tiddlers are created with the same exact date (for example programmatically)
|
||||
I produce the same encoding (because of reversability).
|
||||
I recommend to use nanoID instead to get unique visible different identifiers "
|
||||
| output longDate |
|
||||
longDate := self createdAsTWFormat.
|
||||
output := '' writeStream.
|
||||
output := WriteStream on: ''.
|
||||
1 to: 14 by: 2 do: [ :i |
|
||||
output nextPutAll: (longDate copyFrom: i to: i +1 ) asInteger asCharacterDigit asString
|
||||
output nextPutAll: (longDate copyFrom: i to: i +1) greaseInteger asCharacterDigit greaseString
|
||||
].
|
||||
output nextPutAll: ((longDate copyFrom: 15 to: 17)).
|
||||
output nextPutAll: (longDate copyFrom: 15 to: 17).
|
||||
^ output contents
|
||||
]
|
||||
|
||||
@ -532,7 +537,7 @@ Tiddler >> uid [
|
||||
Tiddler >> uidGenerator [
|
||||
|
||||
self created ifNil: [ self created: self class nowLocal ].
|
||||
^ self customFields at: 'uid' put: self createdEncoded.
|
||||
^ self customFields at: 'uid' put: self createdReversableEncoded.
|
||||
|
||||
]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user