有办法把日期格式时间戳转换回13位时间戳吗

问题_1: 之前做了个签到插件, 现在想加一个连续签到的功能, 但是当时做的时候保存群友的签到日期时, 保存的是日期格式时间戳(如图), 貌似不能直接和13位时间戳比较来加减判断是否是连续的两天.
目标: 有没有简单的办法能把日期格式时间戳转换回13位时间戳, 或者有什么简单一些的办法能比较日期格式时间戳是否是连续的两天.
待定的解决方法_1: 分别提取第1–4位, 第6–7位, 第9–10位来依次比较年, 月, 日. 但是感觉太繁琐了…
待定的解决方法_2: 每次签到判断之前存的时间是否是13位时间戳, 如果不是, 则更新为13位时间戳. 之后直接用时间戳相减并比较, 判断是否为连续两天.

问题_2(可略过): 另外还想实现提示已经连续签到n天, 目前想的方法是将n存为一个键值对, 每次签到看看是否是连续签到, 是的话+1, 不是的话置0. 如果有更简单的方法同样欢迎指教.
image

2 个赞

对不起,我不会用 Blockly。我是来暖贴的,希望小伙伴你在论坛不会那么孤单~

1 个赞

对不起,我不会用 Blockly。我是来暖贴的,希望小伙伴你在论坛不会那么孤单~

2 个赞

方法一:找找有一个叫字符串转列表的块,用“-”做分割符,然后分别比较列表各三项就行。
当然方法二也行

3 个赞

谢谢, 我自己捣鼓一下试试

2 个赞

方法2存在问题, 因为当前和前一次签到时间的时间戳直接作差是没有意义的. 需要直接比较日期格式.

①如果同月, 且日相减=1, 则为连续签到.

②考虑到正好跨月, 以及存在闰年的情况.
判断方法:
-如果当前签到的日=1, 且月份相减=1或-11.(考虑到跨年, 前一个月为12当前的月为1.)
-此时, 如果前一天签到的日为末位的日, 则为连续签到.
排除闰年的影响:
-用一个列表存放每个月对应的天数. 2月记为28.
-如果是2月, 28-29=-1, 28-28=0; 如果是其他月份, 相减=0; 如果不是最后一天, 例如31-29=2.
-因此, 如果每月天数-前一天签到的日≤0, 则为连续签到.

示例如下(不考虑类似<去年1.1签到, 今年1.2签到>的情况):

示例

插件名称: 连续签到
导出时间: 2024/8/18 11:52:47
-=-=-=-=–=-=-=-=- BEGIN KOISHI BLOCKLY BL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