Sha256: 3867500c305e667216fe2b0bc6bdcb139837110028efa68fd1b2eeccccd348a0

Contents?: true

Size: 1.11 KB

Versions: 83

Compression:

Stored size: 1.11 KB

Contents

exercise: Meetup
version: 2
plan: 95
tests: |-
  is meetup-date(.<description>), Date.new(|.<year month dayofmonth>), .<description> for @($c-data<cases>);

unit: module
example: |-
  sub meetup-date (Str:D $desc --> Date:D) is export {
    my (Date $date, Str $day-of-week);
    given $desc.words {
      $date = Date.new: year => .[*-1];

      given .[*-2] {
        $date.=later: months => %(<
          January February March
          April May June
          July August September
          October November December
        >.antipairs){$_}
      }

      $day-of-week = S/day// given .[1].lc;
      $date.=later: days => (given .[0] {
        when 'first'   { 0}
        when 'second'  { 7}
        when 'third'   {14}
        when 'fourth'  {21}
        when /teenth$/ {$day-of-week = S/teenth// given $_; 12}
        when 'last'    {$date.=later(:1month); -7}
      });
    }

    $date.=succ until $date.day-of-week == (given <
      mon tues
      wednes thurs
      fri satur sun
    > {
      %(.values Z=> .keys »+» 1){$day-of-week}
    });

    return $date;
  }

stub: |-
  sub meetup-date ($desc) is export {
  }

Version data entries

83 entries across 83 versions & 1 rubygems

Version Path
trackler-2.2.1.180 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.179 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.178 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.177 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.176 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.175 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.174 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.173 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.172 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.171 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.170 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.169 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.167 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.166 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.165 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.164 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.163 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.162 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.161 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.160 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml