Skip to content

Commit

Permalink
Merge pull request #4 from spoved/v0.1.9
Browse files Browse the repository at this point in the history
V0.1.9
  • Loading branch information
kalinon authored Aug 10, 2022
2 parents f89e341 + c9f5cd7 commit fe39f36
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
12 changes: 7 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ jobs:
- "v1.22"
- "v1.23"
- "v1.24"
include:
- os: ubuntu-latest
- os: ubuntu-latest
crystal: 1.2.2
- os: macos-latest
os:
- ubuntu-latest
- macos-latest
crystal:
- latest
- 1.3
- 1.4
runs-on: ${{ matrix.os }}
steps:
- name: Download source
Expand Down
4 changes: 2 additions & 2 deletions shard.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ authors:
- Holden Omans <[email protected]>
repository: "https://github.com/spoved/k8s.cr"

version: 0.1.8
crystal: ">= 1.2.2, < 2.0.0"
version: 0.1.9
crystal: ">= 1.3.0, < 2.0.0"

targets:
generate:
Expand Down
4 changes: 4 additions & 0 deletions src/k8s/resource/macros.cr
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ macro k8s_cast_type(value, *typs)
{{value}}.to_f
{% end %}
{% end %}
{% if kind <= Time %}
when String
K8S::TimeFormat.parse({{value}})
{% end %}
{% end %}

{% atyps = typs.uniq.select(&.resolve.<=(Array)) %}
Expand Down
6 changes: 5 additions & 1 deletion src/k8s/util/time_format.cr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
struct K8S::TimeFormat
# @@rfc3339_format = ::Time::Format.new("%Y-%m-%dT%TZ")

def parse(string, loc)
def self.parse(string, loc = nil)
if string =~ /\.\d+Z/
::Time.parse_rfc3339(string)
else
Expand All @@ -10,6 +10,10 @@ struct K8S::TimeFormat
end
end

def parse(string, loc = nil)
K8S::TimeFormat.parse(string, loc)
end

def format(value)
Time::Format::RFC_3339.format(value)
end
Expand Down

0 comments on commit fe39f36

Please sign in to comment.