update readme
This commit is contained in:
parent
4222e71644
commit
e1bac3ffb9
18
README.md
18
README.md
@ -51,8 +51,8 @@ timestring.js will parse the following keywords into time values:
|
|||||||
3. `h, hr, hrs, hour, hours` - will parse to hours
|
3. `h, hr, hrs, hour, hours` - will parse to hours
|
||||||
4. `d, day, days` - will parse to days
|
4. `d, day, days` - will parse to days
|
||||||
5. `w, week, weeks` - will parse to weeks
|
5. `w, week, weeks` - will parse to weeks
|
||||||
6. `mth, mths, month`, months - will parse to months
|
6. `mth, mths, month, months` - will parse to months
|
||||||
7. `y, yr, yrs, year`, years - will parse to years
|
7. `y, yr, yrs, year, years` - will parse to years
|
||||||
|
|
||||||
Keywords can be used interchangeably:
|
Keywords can be used interchangeably:
|
||||||
|
|
||||||
@ -84,9 +84,9 @@ var weeks = str.parseTime('w'); // 0.13253968253968254
|
|||||||
|
|
||||||
// or
|
// or
|
||||||
|
|
||||||
var hours = (new Timestring()).parse(str, 'h');
|
var hours = (new Timestring()).parse(str, 'h'); // 22.266666666666666
|
||||||
var days = (new Timestring()).parse(str, 'd');
|
var days = (new Timestring()).parse(str, 'd'); // 0.9277777777777778
|
||||||
var weeks = (new Timestring()).parse(str, 'w');
|
var weeks = (new Timestring()).parse(str, 'w'); // 0.13253968253968254
|
||||||
```
|
```
|
||||||
|
|
||||||
##Optional Configuration
|
##Optional Configuration
|
||||||
@ -124,11 +124,11 @@ var time = (new Timestring(settings)).parse(str, 'h');
|
|||||||
console.log(time) // will log 1
|
console.log(time) // will log 1
|
||||||
```
|
```
|
||||||
|
|
||||||
In the example of above `hoursPerDay` is being set to `1`. When the time string is being parsed, the return value is being specified as hours. Normally `1d` would parse to `24` hours (as by deafult there are 24 hours in a day) but because `hoursPerDay` has been set to `1`, `1d` is now only equal to `1` hour.
|
In the example of above `hoursPerDay` is being set to `1`. When the time string is being parsed, the return value is being specified as hours. Normally `1d` would parse to `24` hours (as by deafult there are 24 hours in a day) but because `hoursPerDay` has been set to `1`, `1d` will now only parse to `1` hour.
|
||||||
|
|
||||||
This would be useful for specific application needs.
|
This would be useful for specific application needs.
|
||||||
|
|
||||||
***Example** - Employees of my company work 7.5 hours a day, and only work 5 days a week. In my time tracking app, when they type `1d` i want 7.5 hours to be tracked. When they type `1w` i want 5 days to be tracked etc.*
|
*Example - Employees of my company work 7.5 hours a day, and only work 5 days a week. In my time tracking app, when they type `1d` i want 7.5 hours to be tracked. When they type `1w` i want 5 days to be tracked etc.*
|
||||||
|
|
||||||
```js
|
```js
|
||||||
var settings = {
|
var settings = {
|
||||||
@ -137,8 +137,8 @@ var settings = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// get time values from form input
|
// get time values from form input
|
||||||
var today = document.querySelector('time-input').value, //'1d'
|
var today = document.querySelector('time-input').value, // '1d'
|
||||||
thisWeek = document.querySelector('time-input').value //'1w';
|
thisWeek = document.querySelector('time-input').value // '1w';
|
||||||
|
|
||||||
// parse times
|
// parse times
|
||||||
var hoursToday = today.parseTime('h', settings),
|
var hoursToday = today.parseTime('h', settings),
|
||||||
|
Loading…
Reference in New Issue
Block a user