Skip to content

Commit 736d49b

Browse files
authored
Merge pull request #26 from Hentioe/instead_time_now
Use Time.utc instead of deprecated Time.now
2 parents 0c7e9dd + 3dc1094 commit 736d49b

File tree

4 files changed

+6
-6
lines changed

4 files changed

+6
-6
lines changed

README.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ Example:
7575

7676
```crystal
7777
# Create token that expires in 1 minute
78-
exp = Time.now.to_unix + 60
78+
exp = Time.utc.to_unix + 60
7979
payload = { "foo" => "bar", "exp" => exp }
8080
token = JWT.encode(payload, "SecretKey", JWT::Algorithm::HS256)
8181
@@ -96,7 +96,7 @@ Example:
9696

9797
```crystal
9898
# Create token that will become acceptable in 1 minute
99-
nbf = Time.now.to_unix + 60
99+
nbf = Time.utc.to_unix + 60
100100
payload = { "foo" => "bar", "nbf" => nbf }
101101
token = JWT.encode(payload, "SecretKey", JWT::Algorithm::HS256)
102102
@@ -110,7 +110,7 @@ From [RFC 7519](https://tools.ietf.org/html/rfc7519#section-4.1.6):
110110
111111
Example:
112112
```crystal
113-
payload = { "foo" => "bar", "iat" => Time.now.to_unix }
113+
payload = { "foo" => "bar", "iat" => Time.utc.to_unix }
114114
token = JWT.encode(payload, "SecretKey", JWT::Algorithm::HS256)
115115
```
116116

examples/exp_claim.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require "../src/jwt"
22

33
# Create token that expires in 1 minute
4-
exp = Time.now.to_unix + 60
4+
exp = Time.utc.to_unix + 60
55
payload = {"foo" => "bar", "exp" => exp}
66
token = JWT.encode(payload, "SecretKey", JWT::Algorithm::HS256)
77

examples/iat_claim.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
require "../src/jwt"
22

33
# Create token with iat claim:
4-
payload = {"foo" => "bar", "iat" => Time.now.to_unix}
4+
payload = {"foo" => "bar", "iat" => Time.utc.to_unix}
55
token = JWT.encode(payload, "SecretKey", JWT::Algorithm::HS256)

examples/nbf_claim.cr

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
require "../src/jwt"
22

33
# Create token that will become acceptable in 1 minute
4-
nbf = Time.now.to_unix + 60
4+
nbf = Time.utc.to_unix + 60
55
payload = {"foo" => "bar", "nbf" => nbf}
66
token = JWT.encode(payload, "SecretKey", JWT::Algorithm::HS256)
77

0 commit comments

Comments
 (0)