Mario Pietsch fa70cee69c Fix date parsing and DateFormat template tokens (#9981)
* Move date tests into their own spec file

Take the two date specs out of test-utils.js and grow them into full
coverage of every token DateFormat documents.

Build every date with the local time constructor, and take the two UTC
expectations from toISOString(), so no assertion restates the code it is
checking.

* Default month and day of a truncated datestamp

A date field holding only a year and a month, for example 202608, built
an invalid date that setUTCFullYear() then rebuilt from the epoch as
1 January, so the month was silently lost.

* Substitute zero and empty valued date tokens

Test the token match rather than the substituted value, so that a value
of zero is not mistaken for no match at all.

* Render hh, mm, ss, XXX and TIMESTAMP when they are zero, and render
  the empty alternative of {era:BCE||CE}
* Stop re-reading the character after such a token as literal text,
  which is why mmss at ten o'clock reported "ss"

* Render a zero timezone offset as +00:00

ISO 8601 has no negative zero offset, and TZD had no zero case.

* Keep summer time out of date arithmetic

Read the UTC components of a date throughout, rather than measuring a
summer time instant against a standard time reference or shifting the
instant by its own offset.

* Correct WW, 0WW, wYYYY and wYY, which were a week out in the hour
  after local midnight in years whose 1 January is a Thursday, and
  ddddd and 0ddddd, which were a day out in the same hour
* Correct a template starting with [UTC], which was out by the summer
  time offset around a transition, and with it the format:timestamp
  filter operator whose default template starts that way
* Report TIMESTAMP as milliseconds since the epoch, which cannot depend
  on the display template, and TZD as +00:00 under [UTC]
* Add $tw.utils.getDayOfYear(), returning 1 to 365, or 366 in a leap
  year

* Show the last two digits of the year in YY

YY and wYY subtracted 2000 instead of taking the last two digits, so
1999 rendered as -1 and 2100 as 100. Years from 2000 to 2099 are
unaffected, which is why this went unnoticed.

* Write a fixed width year in a datestamp

Every component of a datestamp was padded except the year, so a date
before the year 1000 produced a short string that parsed back as a
different date.

* Pad a negative year to four digits

pad() pads with leading zeros, so a short negative year came out as
0-14 rather than -0014. Keep the sign outside the padding.

* Keep an escape out of the substituted text

Take a backslash escape out of the template while reading it, not out
of the finished string, where it consumed whatever the following token
had substituted and left \0MM rendering as a bare month.

Record at the end of the spec file which sweeps were run out of band,
which timezones they used and why, since none of that fits in a spec.

* Document the datestamp format shortcut

The whole template [UTC]YYYY0MM0DD0hh0mm0ssXXX returns the stored
datestamp with padded milliseconds, which NowMacro relies on. Say so
where XXX is defined, since XXX alone is not padded.

Describe the backslash escape as well, now that it takes the character
out of the template rather than out of the finished text.

* Add the release note

* Point the release notes at PR 9981

* Add created and modified to the impact notes

* Move date code comments into the tests

Keep core small by leaving comments only where the next line surprises

* Remove the date formatting and parsing comments from boot.js and
  utils.js, except the three on non-obvious Date API behaviour
* Keep their rationale in test-dates.js next to the tests that guard it
* Test that [UTC] leaves TIMESTAMP unchanged and sets TZD to +00:00
2026-11-28 06:46:05 +01:00
2026-07-10 12:41:53 +02:00
2026-11-01 20:55:22 +00:00
2026-05-05 10:28:28 +01:00
2026-04-20 19:33:07 +01:00
2026-02-20 08:38:42 +00:00
2026-07-10 11:17:53 +02:00
2026-07-10 12:41:53 +02:00
2026-07-10 11:17:53 +02:00

Welcome

Welcome to TiddlyWiki, a non-linear personal web notebook that anyone can use and keep forever, independently of any corporation.

TiddlyWiki is a complete interactive wiki in JavaScript. It can be used as a single HTML file in the browser or as a powerful Node.js application. It is highly customisable: the entire user interface is itself implemented in hackable WikiText.

Demo

Learn more and see it in action at https://tiddlywiki.com/

Developer Documentation

Developer documentation is in progress at https://tiddlywiki.com/dev/

Pull Request Previews

Pull request previews courtesy of Netlify

Deploys by Netlify

Join the Community

User forums

Talk TiddlyWiki

As the official TiddlyWiki forum, Talk TiddlyWiki is a place to talk about TiddlyWiki: requests for help, announcements of new releases and plugins, debating new features, or just sharing experiences. You can participate via the associated website, or subscribe via email.

https://talk.tiddlywiki.org/

Google Groups

For the convenience of existing users, we also continue to operate the original TiddlyWiki group (hosted on Google Groups since 2005): https://groups.google.com/group/TiddlyWiki

Developer forums

Other forums


Installing TiddlyWiki on Node.js

TiddlyWiki is a SingleFileApplication, which is easy to use. For advanced users and developers there is a possibility to use a Node.js client / server configuration. This configuration is also used to build the TiddlyWiki SinglePageApplication

  1. Install Node.js
    • Linux:
      Debian/Ubuntu:
      apt install nodejs
      May need to be followed up by:
      apt install npm
      Arch Linux
      yay -S tiddlywiki
      (installs node and tiddlywiki)
    • Mac
      brew install node
    • Android
    • Other
  2. Open a command line terminal and type:
    npm install -g tiddlywiki
    If it fails with an error you may need to re-run the command as an administrator:
    sudo npm install -g tiddlywiki (Mac/Linux)
  3. Ensure TiddlyWiki is installed by typing:
    tiddlywiki --version
    • In response, you should see TiddlyWiki report its current version (eg "5.4.1". You may also see other debugging information reported.)
  4. Try it out:
    1. tiddlywiki mynewwiki --init server to create a folder for a new wiki that includes server-related components
    2. tiddlywiki mynewwiki --listen to start TiddlyWiki
    3. Visit http://127.0.0.1:8080/ in your browser
    4. Try editing and creating tiddlers
  5. Optionally, make an offline copy:
    • click the save changes button in the sidebar, OR
    • tiddlywiki mynewwiki --build index

The -g flag causes TiddlyWiki to be installed globally. Without it, TiddlyWiki will only be available in the directory where you installed it.

Warning
If you are using Debian or Debian-based Linux and you are receiving a node: command not found error though node.js package is installed, you may need to create a symbolic link between nodejs and node. Consult your distro's manual and whereis to correctly create a link. See github issue 1434.

Example Debian v8.0: sudo ln -s /usr/bin/nodejs /usr/bin/node


Tip
You can also install prior versions like this:
npm install -g tiddlywiki@5.1.13

Using TiddlyWiki on Node.js

TiddlyWiki5 includes a set of commands for use on the command line to perform an extensive set of operations based on TiddlyWikiFolders, TiddlerFiles.

For example, the following command loads the tiddlers from a TiddlyWiki HTML file and then saves one of them in static HTML:

tiddlywiki --verbose --load mywiki.html --render ReadMe ./readme.html

Running tiddlywiki from the command line boots the TiddlyWiki kernel, loads the core plugins and establishes an empty wiki store. It then sequentially processes the command line arguments from left to right. The arguments are separated with spaces.

Introduced in v5.1.20 First, there can be zero or more plugin references identified by the prefix + for plugin names or ++ for a path to a plugin folder. These plugins are loaded in addition to any specified in the TiddlyWikiFolder.

The next argument is the optional path to the TiddlyWikiFolder to be loaded. If not present, then the current directory is used.

The commands and their individual arguments follow, each command being identified by the prefix --.

tiddlywiki [+<pluginname> | ++<pluginpath>] [<wikipath>] [--<command> [<arg>[,<arg>]]]

For example:

tiddlywiki --version
tiddlywiki +plugins/tiddlywiki/filesystem +plugins/tiddlywiki/tiddlyweb mywiki --listen
tiddlywiki ++./mygreatplugin mywiki --listen

Introduced in v5.1.18 Commands such as the ListenCommand that support large numbers of parameters can use NamedCommandParameters to make things less unwieldy. For example:

tiddlywiki wikipath --listen username=jeremy port=8090

See Commands for a full listing of the available commands.

Upgrading TiddlyWiki on Node.js

If you've installed TiddlyWiki on Node.js on the usual way, when a new version is released you can upgrade it with this command:

npm update -g tiddlywiki

On Mac or Linux you'll need to add sudo like this:

sudo npm update -g tiddlywiki

Also see

This readme file was automatically generated by TiddlyWiki

S
Description
A self-contained JavaScript wiki for the browser, Node.js, AWS Lambda etc.
Readme BSD-3-Clause
111 MiB
0 Stars 1 Watchers 0 Forks
Languages
JavaScript 94.7%
JSON 2.5%
TeX 1.2%
Shell 0.8%
CSS 0.6%
Other 0.2%