You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+34-3Lines changed: 34 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,12 +4,43 @@ Random timestamp generator
4
4
## Usage
5
5
randomtimestamp can be used from the command line or imported as a python package.
6
6
7
-
## Command line usage
7
+
###Command line usage
8
8
To use the script from command line
9
9
```
10
-
$ randomtimestamp
10
+
$ python -m randomtimestamp
11
11
30-08-1995 17:58:14
12
12
```
13
13
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
+
15
25
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