$view and date format: Is there anything wrong here?

76 views
Skip to first unread message

Mohammad

unread,
Aug 4, 2019, 11:23:55 AM8/4/19
to TiddlyWiki
In https://tiddlywiki.com/prerelease/

Create an empty tiddler
Then create a field named date with value (eight zeros) 00000000
Then paste the below code

<$view field=date format=date />

I see
1899 11 30 03:25



What is wrong here?

--Mohammad

Jeremy Ruston

unread,
Aug 4, 2019, 1:30:18 PM8/4/19
to tiddl...@googlegroups.com
Hi Mohammad

TiddlyWiki uses the internal function $tw.utils.parseDate() to convert TW format date strings into proper JavaScript dates. In turn, it uses JavaScript’s Date.UTC() method to construct the date from the components:


In this case, we’re calling Date.UTC(0,0,0,0,0,0,0), which happens to return Sun Dec 31 1899 00:00:00 GMT+0000 (Greenwich Mean Time)

I think what’s going on is that 0 is out of range for some values, so some defaults are being used.

Best wishes

Jeremy.


--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/33d8f658-fb2d-4a1c-93d3-a6b91b13da91%40googlegroups.com.

Mark S.

unread,
Aug 4, 2019, 2:50:28 PM8/4/19
to tiddl...@googlegroups.com
It seems like it's using it's own default for the century for anything before AD 99.

I can understand defaults for day of month and month of year, but puzzled why it shouldn't
work with year 0001.

Thanks!

On Sunday, August 4, 2019 at 10:30:18 AM UTC-7, Jeremy Ruston wrote:
Hi Mohammad

TiddlyWiki uses the internal function $tw.utils.parseDate() to convert TW format date strings into proper JavaScript dates. In turn, it uses JavaScript’s Date.UTC() method to construct the date from the components:


In this case, we’re calling Date.UTC(0,0,0,0,0,0,0), which happens to return Sun Dec 31 1899 00:00:00 GMT+0000 (Greenwich Mean Time)

I think what’s going on is that 0 is out of range for some values, so some defaults are being used.

Best wishes

Jeremy.
On 4 Aug 2019, at 16:23, Mohammad <mohamma...@gmail.com> wrote:

In https://tiddlywiki.com/prerelease/

Create an empty tiddler
Then create a field named date with value (eight zeros) 00000000
Then paste the below code

<$view field=date format=date />

I see
1899 11 30 03:25



What is wrong here?

--Mohammad

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddl...@googlegroups.com.

Mark S.

unread,
Aug 4, 2019, 2:51:48 PM8/4/19
to TiddlyWiki
Edit for those using mail:

TonyM

unread,
Aug 4, 2019, 5:32:32 PM8/4/19
to TiddlyWiki
I belive it has being very common to calculate dates based on 1900 01 01 of which the result above is the day before. Years come with leap days and some centuries turn over without a leap day. As a result to be accurate over a long period is quite involved.

Try any date except 0, perhaps 00010000 and see what happens. Zero is famous for divide by zero errors and perhaps year zero never existed.

Calendars are supprisingly complex.

Regards
Tony

Mark S.

unread,
Aug 4, 2019, 6:16:31 PM8/4/19
to TiddlyWiki
I did try 0001 -- dates before 0099 get converted to 1899.

Maybe we should switch to the Mayan calendar. They could track dates back to the 5th century BC.

MagoArcade

unread,
Aug 4, 2019, 6:40:51 PM8/4/19
to TiddlyWiki

On Sunday, 4 August 2019 18:30:18 UTC+1, Jeremy Ruston wrote:
In this case, we’re calling Date.UTC(0,0,0,0,0,0,0), which happens to return Sun Dec 31 1899 00:00:00 GMT+0000 (Greenwich Mean Time)

Hey - that's when I was born! Things were so much simpler then...

TonyM

unread,
Aug 4, 2019, 6:43:21 PM8/4/19
to TiddlyWiki
Mark,

But did the Mayan Calendar not end in recent years - thus the belief the world was coming to an end? 

At least I think it started a new cycle.

Tony

Mohammad

unread,
Aug 4, 2019, 11:58:21 PM8/4/19
to TiddlyWiki
Thanks Jeremy!

Thank you all! By the way I recommend to add a hint somewhere about this in documentation tiddlers.

Interestingly the year digits if starts with 01 returns year 100, but if  starts with 00 returns year 1900

On Sunday, August 4, 2019 at 10:00:18 PM UTC+4:30, Jeremy Ruston wrote:
Hi Mohammad

TiddlyWiki uses the internal function $tw.utils.parseDate() to convert TW format date strings into proper JavaScript dates. In turn, it uses JavaScript’s Date.UTC() method to construct the date from the components:


In this case, we’re calling Date.UTC(0,0,0,0,0,0,0), which happens to return Sun Dec 31 1899 00:00:00 GMT+0000 (Greenwich Mean Time)

I think what’s going on is that 0 is out of range for some values, so some defaults are being used.

Best wishes

Jeremy.
On 4 Aug 2019, at 16:23, Mohammad <mohamma...@gmail.com> wrote:

In https://tiddlywiki.com/prerelease/

Create an empty tiddler
Then create a field named date with value (eight zeros) 00000000
Then paste the below code

<$view field=date format=date />

I see
1899 11 30 03:25



What is wrong here?

--Mohammad

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddl...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages