Skip to content

Commit dde4a38

Browse files
authored
Add quick start (#22)
1 parent 21c772f commit dde4a38

File tree

2 files changed

+39
-2
lines changed

2 files changed

+39
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@ New features:
1111
Bugfixes:
1212

1313
Other improvements:
14-
- Added tests (#20 by @ntwilson)
14+
- Added tests (#20 by @ntwilson)
15+
- Added quick start (#22 by @maxdeviant)
1516

1617
## [v5.0.0](https://github.com/purescript-contrib/purescript-now/releases/tag/v5.0.0) - 2021-02-26
1718

README.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,43 @@ spago install now
1818

1919
## Quick start
2020

21-
The quick start hasn't been written yet (contributions are welcome!). The quick start covers a common, minimal use case for the library, whereas longer examples and tutorials are kept in the [docs directory](./docs).
21+
The functions provided by `now` can be used to get the current date and time from the current machine's system clock.
22+
23+
Here are two example functions that print out the current year and time:
24+
25+
```purs
26+
import Prelude
27+
import Data.DateTime
28+
import Data.Enum
29+
import Effect
30+
import Effect.Console
31+
import Effect.Now
32+
33+
printCurrentYear :: Effect Unit
34+
printCurrentYear = do
35+
currentDate <- nowDate
36+
let
37+
currentYear = fromEnum $ year currentDate :: Int
38+
log $ "The current year is " <> show currentYear
39+
40+
printCurrentTime :: Effect Unit
41+
printCurrentTime = do
42+
currentTime <- nowTime
43+
let
44+
currentHour = fromEnum $ hour currentTime :: Int
45+
currentMinute = fromEnum $ minute currentTime :: Int
46+
log $ "The current time is " <> show currentHour <> ":" <> show currentMinute
47+
```
48+
49+
We can then try these functions out in a REPL:
50+
51+
```
52+
> printCurrentYear
53+
The current year is 2021
54+
55+
> printCurrentTime
56+
The current time is 1:54
57+
```
2258

2359
## Documentation
2460

0 commit comments

Comments
 (0)