https://github.com/cbeer/tc
Timecode parser
https://github.com/cbeer/tc
Last synced: about 1 month ago
JSON representation
Timecode parser
- Host: GitHub
- URL: https://github.com/cbeer/tc
- Owner: cbeer
- License: mit
- Created: 2011-08-10T13:31:41.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2011-08-24T19:47:12.000Z (almost 14 years ago)
- Last Synced: 2025-02-17T05:44:15.720Z (4 months ago)
- Language: Ruby
- Homepage:
- Size: 105 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Tc
Timecode parser (based on Parslet) for parsing arbitrary timecode formats into a standardized format
## Usage
```ruby
parser = Tc::Duration.newparser.parse('00:12:43;23')
# => { :hours => '00', :minutes => '12', :seconds => '43', :frames => '23', :ndf => ';'}parser.parse('123m')
# => { :minutes => '123' }parser.parse('approx. 54s')
# => { :seconds => '54', :approximate => 'approx.' }```
See ```spec/lib/tc_duration.rb``` for additional examples.
Given an ambiguously formatted input (e.g. ```01:34```), Tc will prefer ```hh:mm``` for small values of ```hh``` (<= 2 hours), but ```mm:ss``` in all other cases.