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.119 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.118 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.117 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.116 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.115 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.114 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.113 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.111 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.110 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.109 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.108 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.107 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.106 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.105 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.104 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.103 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.102 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.101 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.100 tracks/perl6/exercises/meetup/.meta/exercise-data.yaml
trackler-2.2.1.99 tracks/perl6/exercises/meetup/example.yaml