<asterite>
Sorry we didn't merge your previous pull request
<Prep>
no worries
<asterite>
but there's the mode_t modification, and also time_t, but time_t doesn't have anything to do with that pull request (so it's hard for us to decide if we should include that)
<Prep>
also, this is not tested on anything other than Darwin yet
<Prep>
well, THIS commit relies on time_t :-)
<Prep>
and I heard waj comment to somu that he wanted small commits
<Prep>
brb, lunch
<asterite>
Hey, the Time additions look really good!
<asterite>
When you say tested, do you mean you have a time_spec.cr file, or did you just try it with some code?
<asterite>
The code looks ok, but without specs it's hard to tell if it works ok (we can believe you, but specs speak more strongly :))
<asterite>
We try to write a spec for everything in Crystal, as long as it's possible
waj has joined #crystal-lang
<Prep>
both
<Prep>
there is an updated spec file included in that commit
<Prep>
although I agree it could be extended a bit more
<asterite>
Oh, sorry, I didn't see the specs before
<asterite>
I like it :)
<Prep>
great!
<Prep>
what do you think on the to_timet on Float? It feels a bit hacky, but I couldn't think of another way that felt less hacky
<asterite>
It's ok
<asterite>
Does Time.now still works?
<asterite>
Ah, yes, I see the spec
<Prep>
I've tried to mimmick Ruby's Time behaviour, without building a full implementation
<Prep>
I wasn't even planning on changing the Time class, but I felt that the File::Stat atime/ctime/mtime needed to return a Time object, so I figured what the hell
kostya has joined #crystal-lang
waj has joined #crystal-lang
<asterite>
@Prep :)
<asterite>
We can eventually make Time a struct, I think. It would just be a wrapper of a float (that's also immutable)
<Prep>
what's the benefit of a struct over a class in this case?
<Prep>
do you mind if I make a pull request for it? Then you won't need to feel so conflicted about approving that earlier pull request with the TimeT alias :P
<asterite>
Sure! Of course
<Prep>
great! I'll drop my earlier pull request, so this one has the changes to ModeT and TimeT included
<asterite>
Great! This time we'll merge it right away :)
<asterite>
Maybe because travis' time zone is different or something?
<Prep>
I can almost guess which test went wrong
<Prep>
hmmm no, I guessed wrong
<asterite>
I'm sure it has something to do with the timezones… the difference I get it 9 hours
CraigBuchek has joined #crystal-lang
<Prep>
yeah, most definately
<Prep>
it's probably easiest to convert to utc before checking the timestamp
<Prep>
I'll put in a fix in a minute
<Prep>
It's in
<Prep>
I removed 1 spec which was a bit nonsensical. It tested strftime, but strftime is already heavily used in the other specs
<asterite>
Good
<Prep>
ouch, still 1 problem it seems
<Prep>
ah, of course
<asterite>
No worries, I remember in some of our rails projects we had to push many times to get the specs related to timezones right :)
<CraigBuchek>
Ugh. Timezones.
<CraigBuchek>
If you get the timezone specs right in the first 12 tries, you've done well.
<Prep>
hahah
<Prep>
well, 3 failed tries so far and my confidence is sinking
<Prep>
I should probably set up a VM with a different timezone
<CraigBuchek>
I spent 2 weeks debugging a timezone issue once. Probably was close to 12 tries. It's just a really complicated issue, especially when you have server timezone, client timezone, and hardware timezone.
<Prep>
well, at least I can reproduce it now in my VM
<Prep>
setting tm_isdst does fix it for travis, but it breaks my local setup
<asterite>
I wish I could help you, but timezones are not my speciality :(
<Prep>
no worries, I'm on the right track. I think I need to figure out if the localally set timezone needs dst or not
<CraigBuchek>
Prep: I think I see the issue.
<CraigBuchek>
So you seem to be initializing the time as UTC (due to utc_offset=0 default argument in the initiializer).
<CraigBuchek>
But then when you call strftime, you're getting the local time (with the call to tm).
<Prep>
yep, I think you got it
<CraigBuchek>
Also, self.local looks wrong - you're passing a utc_offset that you never received.
<Prep>
hey, good find! :-)
<CraigBuchek>
Honestly, I think I wouldn't rely on C to do any of the date manipulation, other than strftime, gettimeofday, and getting the timezone from the locale.
<CraigBuchek>
I hate timezones, but I'm fascinated by time and calendars.
<Prep>
hmmm, I'll see how I can make this work. I'd rather not reinvent the wheel where the C functions can help me out
<Prep>
though so far it's been hit and miss :-)
<Prep>
anyway, thanks for the help, dude
<CraigBuchek>
I'd also be wary of using seconds since the epoch, since it limits your possible dates. I see that you're using a 64-bit float. Not sure what the limits are there, but I'd suspect that you might not be able to handle something like the date the Magna Carta was signed (15 June 1215).
<CraigBuchek>
At the least, be sure to document what the limits are. Also, near the edges, you'll likely get less than 1-second precision.
waj has joined #crystal-lang
<CraigBuchek>
So there's no Date class yet?
<asterite>
@CraigBuchek not yet
<CraigBuchek>
Well, there goes my weekend….
<asterite>
:-P
<CraigBuchek>
No better way to learn the language than helping to build it.
<CraigBuchek>
And to give a presentation on it.
<asterite>
Sure :D
<asterite>
I'm always amazed how much little documentation we have about the language but still, people understand it quickly
<asterite>
and I'm not talking about the syntax
<asterite>
Things like "timespec :: C::TimeSpec" for declaring a struct variable, or using "out" with C libraries
<CraigBuchek>
Well, you have the advantage of being based on Ruby, so knowing Ruby gets you probably 90%+ of the way.
<asterite>
or generic types
<CraigBuchek>
For those who don't really know Ruby, I've found Ruby to be the best by far at the Principal of Least Surprised.
<CraigBuchek>
For the things you've added, I think the spirit of Ruby has lead you to keep those same principles.
<CraigBuchek>
For me so far, I can cargo-cult from existing code, when it diverges from Ruby.
bcardiff has joined #crystal-lang
<asterite>
Yes, we also love ruby
bcardiff has joined #crystal-lang
bcardiff has joined #crystal-lang
asterite has joined #crystal-lang
CraigBuchek has joined #crystal-lang
bcardiff has joined #crystal-lang
waj has joined #crystal-lang
<CraigBuchek>
Hey, is it possible to get icr to run? The wiki says it should be in bin.
<CraigBuchek>
bin/crystal src/compiler/icr.cr wants prompt to be a Char* instead of a String.
<CraigBuchek>
What's the difference between a Struct and a Class?