aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Russell <ac.russell@live.com>2022-07-31 11:30:40 -0400
committerAdam Russell <ac.russell@live.com>2022-07-31 11:30:40 -0400
commit120c33f6513c881cb91cda5a9cee186be7b23ebc (patch)
treeef6ee3a5aeb948f988b20fcb2d0f8a4921c94342
parent8d9f2193a0845244fe88332b213a74eeb1e4f65d (diff)
downloadperlweeklychallenge-club-120c33f6513c881cb91cda5a9cee186be7b23ebc.tar.gz
perlweeklychallenge-club-120c33f6513c881cb91cda5a9cee186be7b23ebc.tar.bz2
perlweeklychallenge-club-120c33f6513c881cb91cda5a9cee186be7b23ebc.zip
Added Fortran solution for 175.1.
-rw-r--r--challenge-175/adam-russell/fortran/ch-1.f27
1 files changed, 27 insertions, 0 deletions
diff --git a/challenge-175/adam-russell/fortran/ch-1.f b/challenge-175/adam-russell/fortran/ch-1.f
new file mode 100644
index 0000000000..d7148a4ab6
--- /dev/null
+++ b/challenge-175/adam-russell/fortran/ch-1.f
@@ -0,0 +1,27 @@
+program last_sunday
+use datetime_module, only: datetime, timedelta, clock
+implicit none
+
+character(10), dimension(12) :: last_sundays
+integer :: month
+do month = 1, 12
+ last_sundays(month) = last_sunday_month(month, 2022)
+ write(*, *) last_sundays(month)
+end do
+
+contains
+
+ function last_sunday_month(month, year) result(sunday)
+ integer, intent(in) :: month, year
+ integer :: day
+ character(10) :: sunday
+ type(datetime) :: date
+ do day = 20, 31
+ date = datetime(year, month, day)
+ if (date % isValid() .and. date % weekday() == 0) then
+ write(sunday, '(i4,a1,i0.2,a1,i2)') year, '-', month, '-', day
+ end if
+ end do
+ end function last_sunday_month
+
+end program last_sunday