TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Go Date Format

154 点作者 shenoybr超过 10 年前

20 条评论

vruiz超过 10 年前
While I got also shocked at first by Go&#x27;s time formatting, is by far the easiest to learn and memorize once you get it.<p>The argument from the issue <a href="https://github.com/golang/go/issues/444" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;golang&#x2F;go&#x2F;issues&#x2F;444</a><p>&gt; It would be much easier to port preexisting code if you could just copy your time formats over.<p>It&#x27;s not really much of an argument, since transforming the sprintf format to Go is a trivial as printing an specific date.
评论 #8945274 未加载
评论 #8944966 未加载
BenDaglish超过 10 年前
Personally, when I first read the spec. for time.Format, I thought &quot;well how bleedin&#x27; sensible is that?!&quot; The <i>only</i> thing that annoys me is that it isn&#x27;t in ISO order (I&#x27;d have preferred 2001-02-03 14:05:06 ), but all that you need to remember is &quot;2006-01&quot; and the rest just falls naturally into place. I&#x27;ve seen a couple of &quot;complaints&quot; about this over the last few days, and I just don&#x27;t understand what the problem is. It&#x27;s logical and neat.
评论 #8948264 未加载
评论 #8944837 未加载
评论 #8945101 未加载
Normati超过 10 年前
It&#x27;s unfortunate that languages are so monolithic. You want to make a language that does concurrency differently and you end up having to design date format strings! Sad that we still don&#x27;t have any kind of common libraries or whatever it might take to just do this a couple of times and let language designers pick and choose the preexisting components they want.
评论 #8944941 未加载
评论 #8944927 未加载
评论 #8944793 未加载
评论 #8944812 未加载
评论 #8945159 未加载
评论 #8944747 未加载
评论 #8945582 未加载
elmin超过 10 年前
I, for one, deeply appreciate any project which isn&#x27;t afraid to do things differently when they decide there&#x27;s a better way. I see it similar to iOS not supporting Flash, or Angular 2.0 rethinking things.<p>You can&#x27;t change everything, but it&#x27;s what you do differently that gives your project value.
评论 #8944975 未加载
评论 #8944748 未加载
评论 #8944697 未加载
lohengramm超过 10 年前
I personally love the way it works. This is actually one of my arguments in favor of the golang standard library which is, in my opinion, a great piece of software by itself.
nemothekid超过 10 年前
The Go date format is one my huge annoyances about the language (not generics, interface{} magic, or the lack of immutable types). My biggest issue is that despite the fact the designers call Strftime bad because no one remembers the letters, and has to have documentation handy - the Go docs don&#x27;t even document the magic numbers you have to use.<p>Why 2006? How do I represent a day? When do I use _2 vs 2? Its very poorly documented and thankfully all I use is RFC3339 and Unix timestamps.
评论 #8944785 未加载
svisser超过 10 年前
Strangely the non-profanity version <a href="http://flippinggodateformat.com" rel="nofollow">http:&#x2F;&#x2F;flippinggodateformat.com</a> still has profanity.
评论 #8944630 未加载
YesThatTom2超过 10 年前
I generally agree with Cox but &quot;no one remembers all the letters, so the only way to use it is with documentation in hand.&quot;<p>Huh?<p>Who can remember the numbers? The only way to use this format is with the documentation.<p>It is an easier to read and verify format. However if you think a casual user will remember that &quot;02&quot; is hour and &quot;03&quot; is... wait, is 02 hour? Let me check the documentation.
评论 #8945256 未加载
twotwotwo超过 10 年前
First: neat, funny (&quot;I can now write Go date format strings...you win this time&quot;), and I follow the &quot;sprintf may be awful but at least I know it&quot; argument.<p>While there&#x27;s a lot to say for sticking to your language&#x27;s idioms even when it&#x27;s a pain, if you <i>really</i> need&#x2F;want strftime there are third-party libraries:<p><a href="https://github.com/search?l=Go&amp;q=strftime" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;search?l=Go&amp;q=strftime</a>
adsche超过 10 年前
&gt; Because I&#x27;ve used sprintf a million times before<p>Did you mean strftime?
评论 #8944873 未加载
nothrabannosir超过 10 年前
People who say &quot;he could just use sprintf&quot; are missing the point: this lets you use sprintf <i>while writing idiomatic Go</i>.<p>If I see a Go programmer import a sprintf library just because he doesn&#x27;t want to conform to the programming environment, that&#x27;s going to ruffle some feathers during code review.<p>But if he uses this, well, I&#x27;d be none the wiser.<p>Readability counts.
评论 #8945021 未加载
arvinsim超过 10 年前
I just recently had this problem while working with Hugo, a Go static site generator.<p>Suffice to say, it was not intuitive at all. I had to look at the support forums to learn about this Go eccentricity.<p>I can&#x27;t say that I hate it. I could probably get used to it.
guard-of-terra超过 10 年前
I was wondering why they didn&#x27;t borrow java SimpleDateFormat<p>But then I noticed they decided to tackle the dd-MM-yyyyTHH:mm:ss problem AKA crazy case. Which is kind of noble.
adwf超过 10 年前
I understand there may be legacy issues from other languages, but in a new language... why on earth would you not take the time to make %p the lower case am&#x2F;pm and %P - AM&#x2F;PM?
f2f超过 10 年前
TIL that the hardest thing to do in computer science is to learn something new and different.
评论 #8944800 未加载
评论 #8944990 未加载
评论 #8945472 未加载
RubyPinch超过 10 年前
grey on white, lightgrey on white, yellow on white<p>my oh my, my slightly blurred vision is having fun
squiguy7超过 10 年前
I&#x27;m no designer but that yellow color used on the site is not easy to read.
pbreit超过 10 年前
I appreciate the &quot;flipping&quot; version but why such an obnoxiously immature primary domain?
评论 #8944757 未加载
评论 #8944838 未加载
评论 #8944740 未加载
评论 #8944731 未加载
peterwwillis超过 10 年前
Who the fuck <i>buys a domain name and sets up a web site</i> just because they&#x27;re frustrated at a date format? I don&#x27;t get kids today.
评论 #8944819 未加载
Htsthbjig超过 10 年前
There are two thing I don&#x27;t like in IT:<p>1- Using names for software that is confusing with names of real things that have nothing to do with it, like Cocoa for a user interface library and so many others.<p>2- Using the terms a two year old will use when she discovers it is funny and gets attention just for saying dirty words.<p>In this particular case, this combines both in one. The first thing I thought was: This will have something to do with dating and having casual sex or something. Then you discover that no, it has nothing to do with it, it is just a two year old like mindset creating a &quot;funny&quot;(for him) name for their pet project.
评论 #8944777 未加载
评论 #8944699 未加载
评论 #8944704 未加载
评论 #8944729 未加载