Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion shard.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: myst
version: 0.3.0
crystal: 0.24.1
crystal: 0.26.1
license: MIT
authors:
- Jon Egeland <jonegeland@gmail.com>
Expand Down
6 changes: 5 additions & 1 deletion src/myst/interpreter/native_lib/file.cr
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,11 @@ module Myst
end

NativeLib.method :static_File_lines, MTValue, file_name : String do
TList.new(File.each_line(file_name).map{ |l| l.as(MTValue) }.to_a)
lines = File.open(file_name) do |file|
file.each_line.map { |l| l.as(MTValue) }.to_a
end

TList.new(lines)
end


Expand Down
6 changes: 3 additions & 3 deletions src/myst/interpreter/native_lib/time.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Myst
class Interpreter
NativeLib.method :static_time_now, MTValue do
seconds, nanoseconds = Crystal::System::Time.compute_utc_seconds_and_nanoseconds
offset = Crystal::System::Time.compute_utc_offset(seconds)
offset = Time.new(seconds: seconds, nanoseconds: nanoseconds, location: Time::Location.local).offset

instance = NativeLib.instantiate(self, this.as(TType), [
seconds + offset,
Expand All @@ -18,7 +18,7 @@ module Myst
if format
crystal_time.to_s(format)
else
crystal_time.to_s
crystal_time.to_s("%Y-%m-%d %H:%M:%S")
end
end

Expand All @@ -35,7 +35,7 @@ module Myst
Time.new(
seconds: myst_time.ivars["@seconds"].as(Int64),
nanoseconds: myst_time.ivars["@nanoseconds"].as(Int64).to_i32,
kind: Time::Kind::Unspecified
location: Time::Location::UTC
)
end
end
Expand Down