撸了个年度进度条提示工具

2018-03-21 00:31:04 +08:00
 0xABCD

人生苦短,要时刻提醒自己时间在流逝。

安装:
$ pip install datebar

使用:
$ datebar
passed days: 79
the progress of the year: 22%
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░22%

Github:
https://github.com/Neulana/datebar

喜欢自取,能赏个 star 就更好啦!比心

5808 次点击
所在节点    Python
24 条回复
Williamwang
2018-03-21 07:14:44 +08:00
手机下载即刻 app,关注对应主题,并开启推送就搞定了……
TimCheng
2018-03-21 07:29:59 +08:00
等着接我的 star 吧
0xABCD
2018-03-21 08:27:25 +08:00
@Williamwang 回头下一个试试
0xABCD
2018-03-21 08:27:44 +08:00
gimp
2018-03-21 08:37:36 +08:00
gihnius
2018-03-21 08:42:53 +08:00
写个 Ruby 的玩玩:
percent = ((Time.now.yday.to_f / Time.now.at_end_of_year.yday) * 100).round
bar = '▓' * percent + '░' * (100 - percent)
puts "Progress of this year:"
puts(bar + percent.to_s + '%')

输出:
Progress of this year:
▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓▓░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░22%
anson2416
2018-03-21 09:00:20 +08:00
excel 能做吗
326029212
2018-03-21 09:03:01 +08:00
测试对 python2 稍有不兼容.随手提了个合并
ZeroW
2018-03-21 09:21:13 +08:00
@Williamwang 什么意思,好像不太明白~
jasonyang9
2018-03-21 09:29:35 +08:00
坐等 PHP 版
gihnius
2018-03-21 09:31:20 +08:00
再写个 Go 的:
package main

import (
"fmt"
"math"
"strings"
"time"
)

func main() {
now := time.Now()
passed := now.YearDay()
format := "2006-01-02 15:04:05"
end, _ := time.Parse(format, fmt.Sprintf("%d-12-31 23:59:59", now.Year()))
total := end.YearDay()
progress := math.Round((float64(passed) / float64(total)) * 100)
bar := strings.Repeat("▓", int(progress)) + strings.Repeat("░", (100-int(progress)))
fmt.Printf("Progress of this year %d of %d:\n", passed, total)
fmt.Println(bar)
}

感觉够折腾的。。。。。
clino
2018-03-21 09:32:38 +08:00
0xABCD
2018-03-21 09:49:02 +08:00
@gihnius 感觉 Ruby 跟 Python 真的很像啊
0xABCD
2018-03-21 09:53:12 +08:00
@326029212 多谢了
0vels
2018-03-21 10:09:00 +08:00
之前做过一个农历版的,代码太烂,不好意思贴地址了
0xABCD
2018-03-21 10:09:26 +08:00
@gihnius 为你的折腾精神点赞👍
lrxiao
2018-03-21 10:23:10 +08:00
kaminono
2018-03-21 10:27:51 +08:00
可以 fork 吗?
0xABCD
2018-03-21 10:31:44 +08:00
@lixycoderfix 当然
Williamwang
2018-03-21 11:44:17 +08:00
@zerowang317 #9 即刻 app 有对应的提醒主题

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/439916

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX