From dce99b63d460e8c84cc198b864b75c277f0d484a Mon Sep 17 00:00:00 2001 From: Dawn Rose <63545980+tastethedream@users.noreply.github.com> Date: Mon, 5 Dec 2022 17:32:40 +0000 Subject: [PATCH] Create ex4-6.md Code for new section added to reflect QC2 section 3.4 --- ch04/ex4-6.md | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 ch04/ex4-6.md diff --git a/ch04/ex4-6.md b/ch04/ex4-6.md new file mode 100644 index 0000000..029285c --- /dev/null +++ b/ch04/ex4-6.md @@ -0,0 +1,18 @@ +# Returning Values from Functions + +```dart +void main() { + DateTime timeNow = getCurrentDateTime(0); + DateTime timeDifference = getCurrentDateTime(-7); + + print('The time now is: $timeNow'); + print('The time minus 7 hours is: $timeDifference'); +} +DateTime getCurrentDateTime(int hourDifference) { + DateTime timeNow = DateTime.now(); + DateTime timeDifference = timeNow.add(Duration(hours: hourDifference)); + + return timeDifference; +} + +```