Skip to content
a fast strpitme engine
C Ruby Shell
Branch: master
Clone or download
Latest commit 802c028 Jan 4, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin Initial commit. Jun 8, 2015
ext/strptime strftime: Support %b format Dec 29, 2017
lib v0.2.3 Jan 4, 2018
spec strftime: Support %b format Dec 29, 2017
.clang-format Apply clang-format Aug 25, 2015
.gitignore Initial commit. Jun 8, 2015
.rspec Initial commit. Jun 8, 2015
.travis.yml Add 2.5.0 to .travis.yml Dec 25, 2017
Gemfile Initial commit. Jun 8, 2015
LICENSE.txt Initial commit. Jun 8, 2015
README.md Add Strftime usage Jan 4, 2018
Rakefile Add Ruby 2.5.0 to Rakefile Dec 25, 2017
appveyor.yml Revert "appveyor: Add Ruby 2.3" Mar 28, 2016
strptime.gemspec Add strftime Nov 22, 2017

README.md

Strptime

Build Status Build status

Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file lib/strptime. To experiment with that code, run bin/console for an interactive prompt.

TODO: Delete this and the text above, and describe your gem

Installation

Add this line to your application's Gemfile:

gem 'strptime'

And then execute:

$ bundle

Or install it yourself as:

$ gem install strptime

Usage

Strptime for time parsing

require 'strptime'
parser = Strptime.new('%Y-%m-%dT%H:%M:%S%z')
parser.exec('2015-12-25T12:34:56+09') #=> 2015-12-25 12:34:56 +09:00
parser.execi('2015-12-25T12:34:56+09') #=> 1451014496

Strftime for time formatting

require 'strptime'
now = Time.now
formatter = Strftime.new('%Y-%m-%dT%H:%M:%S.%L %z')
formatter.exec(now)        # 2017-12-29T07:24:31.505 +0900
formatter.execi(now.to_i)  # 2017-12-28T22:24:31.000 +0000

Contributing

  1. Fork it ( https://github.com/nurse/strptime/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request
You can’t perform that action at this time.