Skip to content

Commit fb90563

Browse files
authored
Update README.md
1 parent 9f5f8f9 commit fb90563

1 file changed

Lines changed: 34 additions & 3 deletions

File tree

README.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,43 @@ Random timestamp generator
44
## Usage
55
randomtimestamp can be used from the command line or imported as a python package.
66

7-
## Command line usage
7+
### Command line usage
88
To use the script from command line
99
```
10-
$ randomtimestamp
10+
$ python -m randomtimestamp
1111
30-08-1995 17:58:14
1212
```
1313

14-
## Python Package Usage
14+
### Python Package Usage
15+
16+
The function **randomtimestamp** takes two optional arguments:
17+
```
18+
randomtimestamp(start_year=1950,text=True)
19+
```
20+
The default values of **start_year** and **text** are *1950* and *True* respectively.
21+
The timestamp is generated between *1950* and current year (*datetime.now().year*). Although a year before 1950 could have been used, but it didn't seem to be necessary.
22+
23+
By default, the function returns the output as string in format (**DD-MM-YYYY HH:MM:SS**), where **HH** is in 24-hour format. Setting **text=False** returns a *datetime* object.
24+
1525
Here are examples of all the possible syntaxes:
26+
```
27+
>>>from randomtimestamp import randomtimestamp
28+
29+
>>>randomtimestamp()
30+
'02-06-1970 23:34:10'
31+
32+
>>>randomtimestamp(2010)
33+
'02-06-2013 23:34:10'
34+
35+
>>>randomtimestamp(start_year=2005)
36+
'10-04-2015 10:55:02'
37+
38+
>>>randomtimestamp(2010,False)
39+
datetime.datetime(2010, 5, 16, 3, 32, 18)
40+
41+
>>>randomtimestamp(text=False)
42+
datetime.datetime(1951, 2, 13, 18, 19, 1)
43+
```
44+
45+
## License
46+
This project is released under [GNU GENERAL PUBLIC LICENSE V3](https://www.gnu.org/licenses/gpl-3.0.en.html).

0 commit comments

Comments
 (0)