wenyan-lang / wenyan

文言文編程語言 A programming language for the ancient Chinese.
https://wy-lang.org/
MIT License
19.6k stars 1.1k forks source link

Function「彼年何年」issue: use 黄帝纪元四千七百一十六年 as an example #489

Open kaiyuan01 opened 4 years ago

kaiyuan01 commented 4 years ago

黄帝纪元四千七百一十六年 is Year 2018, yet the function returns 1969:

施「彼年何年」於四千七百一十六

, we get:

一千九百六十九

Is this a bug?

statementreply commented 4 years ago

The input of 彼年何年 is Unix timestamp. See also https://github.com/LingDong-/wenyan-lang/pull/487#issuecomment-570838787

kaiyuan01 commented 4 years ago

Thanks for the reply.

Here is the definition from Li Fa:

注曰「「彼年何年。同Javascript之new Date(x * 1000).getFullYear() for modern dates, in Chinese calendar也。」」 今有一術。名之曰「彼年何年」。欲行是術。必先得一數。曰「時」。乃行是術曰。 施「彼年積何年」於「時」。減其以二六九七。乃得矣。 是謂「彼年何年」之術也。

注曰「「彼年積何年。同Javascript之new Date(x * 1000).getFullYear() + 2697, in Chinese calendar也。」」 今有一術。名之曰「彼年積何年」。欲行是術。必先得一數。曰「時」。乃行是術曰。 施「彼月積何月」於「時」。名之曰「積月」。 夫「積月」。取一以施「月積何閏月」。名之曰「積閏月」。 減「積月」以「積閏月」。除其以十二。取一以施「取底」。乃得矣。 是謂「彼年積何年」之術也。

From "減其以二六九七。乃得矣。" I think it's based on Chinese calendar. If the input is the number of seconds after epoch time in Linux, that output might make sense. (4716 secs past beginning of 1970 is Year 1969 in Chinese calendar)

Should we name it "彼何年" instead of "彼何年" to avoid confusion since the input is in secs instead of years?

LingDong- commented 4 years ago

Should we name it "彼時何年" instead of "彼年何年" to avoid confusion since the input is in secs instead of years?

Good suggestion, however, there is only one problem, which is also means the (Chinese) hour. It has the potential to cause even greater confusion. Also, this repetition of the second and fourth characters in these function names comes from 今夕何夕, 今日何日, etc. and has a poetic quality to it. Of course, clarity is also important. We'll need to consider this more.

cuixiping commented 4 years ago

Does it mean 彼秒何年?