From f79e106471359d6c1f60a4896909d7ebe8c3eeda Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Po=C5=82tyn?= Date: Mon, 4 Nov 2013 16:27:24 +0000 Subject: [PATCH 1/2] Add Ruby examples --- API.md | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/API.md b/API.md index 874b439..a9d8824 100644 --- a/API.md +++ b/API.md @@ -574,6 +574,17 @@ In Python you can get it with something like: ```python calendar.timegm(datetime_object.timetuple()) * 1000 ``` +In Ruby you can get it using `#to_i` method on [`Time`](http://apidock.com/ruby/Time/to_i) object. +If you're using `active_support` gem (default for Ruby on Rails application) `#to_i` is also available on `DateTime` and `ActiveSupport::TimeWithZone` objects. +After that multiply the result by 1000: + +```ruby +Time.now.to_i * 1000 # => 1383582043000 +# ActiveSupport examples: +DateTime.now.to_i * 1000 # => 1383582043000 +ActiveSupport::TimeZone.new('Asia/Shanghai').now.to_i * 100 +# => 1383582043000 +``` In .NET you can get it with something like: From 2cc2ab8975d7e14520300ee5c90a8562b7424671 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Po=C5=82tyn?= Date: Mon, 4 Nov 2013 16:29:17 +0000 Subject: [PATCH 2/2] typo in ActiveSupport::TimeWithZone example --- API.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/API.md b/API.md index a9d8824..4bd3d6a 100644 --- a/API.md +++ b/API.md @@ -582,7 +582,7 @@ After that multiply the result by 1000: Time.now.to_i * 1000 # => 1383582043000 # ActiveSupport examples: DateTime.now.to_i * 1000 # => 1383582043000 -ActiveSupport::TimeZone.new('Asia/Shanghai').now.to_i * 100 +ActiveSupport::TimeZone.new('Asia/Shanghai').now.to_i * 1000 # => 1383582043000 ```