wenyan-lang/wenyan

吾嘗觀『曆法』之書 (Date library implementation proposal)

Open

#425 opened on Dec 29, 2019

View on GitHub
 (6 comments) (4 reactions) (0 assignees)TypeScript (19,271 stars) (1,096 forks)batch import
help wantedstdlib

Description

I have an idea on the implementation of date library:

Wenyan JS equivalent
吾有一時。名之曰「今」。 var 今 = new Date();
吾有一時。曰二千八年八月八日八時八分八秒。名之曰「昔」。 var 昔 = new Date(2008, 8 - 1, 8, 8, 8, 8);
夫「今」之年。 今.getFullYear();
夫「今」之月。 今.getMonth() + 1;
夫「今」之日。 今.getDate();
夫「今」之時。 今.getHours();
夫「今」之分。 今.getMinutes();
夫「今」之秒。 今.getSeconds();
夫「今」之毫秒。 今.getMilliseconds();
夫「今」之曜。 今.getDay();
昔之「昔」之年者。今二千十八是矣。 昔.setFullYear(2018);
昔之「昔」之月者。今十二是矣。 昔.setMonth(12 - 1);

TODO add functions for date-time calculations (no JS equivalents yet)

Contributor guide