Skip to content

Commit

Permalink
Use Time.utc instead of Time.now
Browse files Browse the repository at this point in the history
  • Loading branch information
Hentioe committed Dec 12, 2019
1 parent 0c7e9dd commit 3dc1094
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ Example:

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

```crystal
# Create token that will become acceptable in 1 minute
nbf = Time.now.to_unix + 60
nbf = Time.utc.to_unix + 60
payload = { "foo" => "bar", "nbf" => nbf }
token = JWT.encode(payload, "SecretKey", JWT::Algorithm::HS256)
Expand All @@ -110,7 +110,7 @@ From [RFC 7519](https://tools.ietf.org/html/rfc7519#section-4.1.6):
Example:
```crystal
payload = { "foo" => "bar", "iat" => Time.now.to_unix }
payload = { "foo" => "bar", "iat" => Time.utc.to_unix }
token = JWT.encode(payload, "SecretKey", JWT::Algorithm::HS256)
```

Expand Down
2 changes: 1 addition & 1 deletion examples/exp_claim.cr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "../src/jwt"

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

Expand Down
2 changes: 1 addition & 1 deletion examples/iat_claim.cr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
require "../src/jwt"

# Create token with iat claim:
payload = {"foo" => "bar", "iat" => Time.now.to_unix}
payload = {"foo" => "bar", "iat" => Time.utc.to_unix}
token = JWT.encode(payload, "SecretKey", JWT::Algorithm::HS256)
2 changes: 1 addition & 1 deletion examples/nbf_claim.cr
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
require "../src/jwt"

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

Expand Down

0 comments on commit 3dc1094

Please sign in to comment.