Skip to main content
added 20 characters in body; edited body
Source Link
Peter Taylor
  • 43.1k
  • 4
  • 70
  • 169

Perl, no date library: 160160 159 155

sub f{($y,$m)=split/-/,@_[0],2;$y++if($m>'02-28');$y=(($y+3)>>2%400>>2;$y+=$y&&!($y%25)%100;@r=;@r=(Sun,Mon,Tues,Wednes,Thurs,Fri,Satur,Sun,Mon);@r[(2+5*$y+4*($y/25&3)+2*(5*$y-($y-1)/25&3))%7]."day";}

The real benefit of these date libraries is pushing off the length of the names of the days to someone else.

On the other hand, I think this is the only solution so far which works regardless of locale.

Perl, no date library: 160

sub f{($y,$m)=split/-/,@_[0],2;$y++if($m>'02-28');$y=(($y+3)>>2)%100;@r=(Sun,Mon,Tues,Wednes,Thurs,Fri,Satur);@r[(2+5*$y+4*($y/25&3)+2*(($y-1)/25&3))%7]."day";}

The real benefit of these date libraries is pushing off the length of the names of the days to someone else.

On the other hand, I think this is the only solution so far which works regardless of locale.

Perl, no date library: 160 159 155

sub f{($y,$m)=split/-/,@_[0],2;$y++if($m>'02-28');$y=($y+3)%400>>2;$y+=$y&&!($y%25);@r=(Tues,Wednes,Thurs,Fri,Satur,Sun,Mon);@r[(5*$y-($y/25&3))%7]."day";}

The real benefit of these date libraries is pushing off the length of the names of the days to someone else.

On the other hand, I think this is the only solution so far which works regardless of locale.

added 1 characters in body
Source Link
Peter Taylor
  • 43.1k
  • 4
  • 70
  • 169

Perl, no date library: 160

 
sub f{$_=@_[0];s($y,$m)=split/-//g;$d=0;$y=4;while,@_[0],2;$y++if(229+10000*$y<$_$m>'02-28'){$y+=4;$d+=5;if;$y=(!($y%100$y+3)&&$y%400>>2){$y+=4;$d+=4;}}@r=%100;@r=(Sun,Mon,Tues,Wednes,Thurs,Fri,Satur);@r[$d%7];@r[(2+5*$y+4*($y/25&3)+2*(($y-1)/25&3))%7]."day";} 

The real benefit of these date libraries is pushing off the length of the names of the days to someone else.

On the other hand, I think this is the only solution so far which works regardless of locale.

Perl, no date library: 160

sub f{$_=@_[0];s/-//g;$d=0;$y=4;while(229+10000*$y<$_){$y+=4;$d+=5;if(!($y%100)&&$y%400){$y+=4;$d+=4;}}@r=(Sun,Mon,Tues,Wednes,Thurs,Fri,Satur);@r[$d%7]."day";}

The real benefit of these date libraries is pushing off the length of the names of the days to someone else.

On the other hand, I think this is the only solution so far which works regardless of locale.

Perl, no date library: 160

 
sub f{($y,$m)=split/-/,@_[0],2;$y++if($m>'02-28');$y=(($y+3)>>2)%100;@r=(Sun,Mon,Tues,Wednes,Thurs,Fri,Satur);@r[(2+5*$y+4*($y/25&3)+2*(($y-1)/25&3))%7]."day";} 

The real benefit of these date libraries is pushing off the length of the names of the days to someone else.

On the other hand, I think this is the only solution so far which works regardless of locale.

added 97 characters in body
Source Link
Peter Taylor
  • 43.1k
  • 4
  • 70
  • 169

Perl, no date library: 160

sub f{$_=@_[0];s/-//g;$d=0;$y=4;while(229+10000*$y<$_){$y+=4;$d+=5;if(!($y%100)&&$y%400){$y+=4;$d+=4;}}@r=(Sun,Mon,Tues,Wednes,Thurs,Fri,Satur);@r[$d%7]."day";}

The real benefit of these date libraries is pushing off the length of the names of the days to someone else.

On the other hand, I think this is the only solution so far which works regardless of locale.

Perl, no date library: 160

sub f{$_=@_[0];s/-//g;$d=0;$y=4;while(229+10000*$y<$_){$y+=4;$d+=5;if(!($y%100)&&$y%400){$y+=4;$d+=4;}}@r=(Sun,Mon,Tues,Wednes,Thurs,Fri,Satur);@r[$d%7]."day";}

The real benefit of these date libraries is pushing off the length of the names of the days to someone else.

Perl, no date library: 160

sub f{$_=@_[0];s/-//g;$d=0;$y=4;while(229+10000*$y<$_){$y+=4;$d+=5;if(!($y%100)&&$y%400){$y+=4;$d+=4;}}@r=(Sun,Mon,Tues,Wednes,Thurs,Fri,Satur);@r[$d%7]."day";}

The real benefit of these date libraries is pushing off the length of the names of the days to someone else.

On the other hand, I think this is the only solution so far which works regardless of locale.

Source Link
Peter Taylor
  • 43.1k
  • 4
  • 70
  • 169
Loading