g | x | w | all
Bytes Lang Time Link
097Clojure250703T090025ZMartin P
117TSQL250625T164921ZBradC
072Red250625T112257ZGalen Iv
079Tcl250625T091211Zsergiol
nanRust231123T003303Z138 Aspe
051Perl 5 MTimeLocal pa241030T203657ZXcali
089Rust241030T113751ZFred
008Japt x190213T104823ZShaggy
114Go231120T163344Zbigyihsu
047JavaScript Node.js231119T233239Zcorvus_1
047JavaScript190213T110231ZShaggy
036bash131211T125739ZF. Hauri
107Scala 3231120T005031Z138 Aspe
095Lua231119T215836Zbluswimm
076C231119T195513ZToby Spe
081PHP170301T180309ZTitus
055PHP170301T180122ZTitus
187Clojure170301T163347ZCarcigen
029APL Dyalog APL with cal from dfns170301T105104ZAdá
053Perl 6161214T100005Zbb94
nan140410T142459ZWrzlprmf
204Python 195 /131210T233210Zklingt.n
149Common Lisp CLISP131211T113708ZAinsley
070JavaScript131211T105353Zguy777
086Python2.7131211T143518Zejrb
068Scala140410T153129ZKarol S
nanC++ Too many bytes140409T172431ZCompuChi
039Bash and Sed140408T202834ZNot that
063Rebol140408T131835Zdraegtun
082PHP140408T134217Zdkasipov
086In Smalltalk Squeak/Pharo flavour131212T122849Zaka.nice
092C# 110 101 93131211T114849ZKami
047Bash131211T105401Zjerous
130C131211T202033Zuser1354
050Powershell131210T215154ZDanko Du
042K131211T150903Ztmartin
042Mathematica131210T210915ZDavidC
055Perl + lib POSIX131211T124000ZF. Hauri
nan131211T092624Zskeevey
120Pythonv2131211T112758Zleancz
287C 301+131211T095438ZWilliham
057R131211T024433Zflodel
046Ruby131210T214031Zhistocra

Clojure, 97 bytes

#(count(filter(fn[n](= 5(.getValue(.getDayOfWeek(java.time.LocalDate/of % n 13)))))(range 1 13)))

T-SQL, 117 bytes

SELECT COUNT(*)FROM t,spt_values
WHERE type='P'AND number>0AND number<13AND DATEPART(dw,DATEFROMPARTS(y,number,13))=6

The year is taken as input from a pre-existing table t with INT column y, per our input standards.

Must be run in database master, which contains a system table spt_values that has (among other things) the numbers 1-12.

You might need to use a different value than "6" if your server's "DATEFIRST" setting is not the US English default.

Red, 72 bytes

func[y][n: 0 repeat m 12[d: to now reduce[1 m y]if d/10 = 7[n: n + 1]]n]

Try it online!

Tcl, 79 81 119 126 127 129 130 bytes

proc F y {time {if ![clock f [clock sc [incr i]/1/$y] -f %w] incr\ t} 12
set t}

Try it online!

Rust, 103 102 bytes

Saved 1 byte(s) thanks to @ceilingcat


Golfed version. Run it on Rust Playground!

fn c(y:i32)->i32{(1..13).filter(|m|NaiveDate::from_ymd(y,*m,6).weekday()==Weekday::Fri).count()as i32}

Ungolfed version. Run it on Rust Playground!

use chrono::{Datelike, Weekday, NaiveDate};

fn main() {
    println!("{}", count_fridays(1776));
    println!("{}", count_fridays(2012));
    println!("{}", count_fridays(2013));
    println!("{}", count_fridays(2014));
}

fn count_fridays(year: i32) -> i32 {
    let mut count = 0;
    for month in 1..=12 {
        let date = NaiveDate::from_ymd(year, month, 6);
        if date.weekday() == Weekday::Fri {
            count += 1;
        }
    }
    count
}

Perl 5 -MTime::Local -pa, 51 bytes

$_=grep!(gmtime timegm+(1)x4,$_,"@F"-1900)[6],0..11

Try it online!

Rust, 89 bytes

Here is a shorter version of the previous Rust answer. The program was shortened by using a closure instead of a function. The actual code-golfed line of code is 93 characters long, the rest is similar supporting code to the previous version.

// rust leap year
use chrono::{Datelike, Weekday, NaiveDate};

fn main() {

let c=|y|(1..=12).filter(|m|NaiveDate::from_ymd(y,*m,6).weekday()==Weekday::Fri).count();

    println!("{}", c(1776));
    println!("{}", c(2012));
    println!("{}", c(2013));
    println!("{}", c(2014));

Japt -x, 10 8 bytes

CÆ!ÐUX e

Try it

CÆ!ÐUX e     :Implicit input of integer U
C            :12
 Æ           :Map the range [0,C)
  !          :  Logical NOT of
   Ð         :    Construct Date object with
    U        :      Year U
     X       :      0-based month X (and implicit date 1)
       e     :    0-based day of the week
             :Implicit output of sum of resulting array

Go, 114 bytes

import."time"
func f(y int)(c int){for i:=0;i<12;i++{if Date(y,Month(i+1),1,0,0,0,0,UTC).Weekday()<1{c++}}
return}

Counts months starting with Sundays.

Attempt This Online!

JavaScript (Node.js), 47 bytes

f=(y,m=12)=>m&&f(y,--m)+!new Date(y,m).getDay()

Attempt This Online!

-2 bytes thanks to l4m2

JavaScript, 56 47 bytes

f=(y,m=12)=>m&&f(y,--m)+!new Date(y,m).getDay()

Try It Online!

bash 47 36

seq -f$1-%g-6 12|date -f-|grep -c ^F

Thanks @DigitalTrauma for saving 10 chars by using seq with default start to 1.

date -f<(printf "%s\n" $1-{1..12}-6)|grep -c ^F

(Previous version using echo present a bug because of the empty line when <(echo $1-{1..12}-6$'\n'). So this function worked fine until today is a Friday.

Lets see:

set -- 2013
seq -f$1-%g-6 1 12|date -f-|grep -c ^F
2

date -f<(printf "%s\n" $1-{1..12}-13)|grep -c ^F
2

This is locale dependant, so if this don't work, you may have to

export LANG=C

or

LANG=C date -f<(printf "%s\n" $1-{1..12}-13)|grep -c ^F

Into a function; +7 -> 43

f(){ seq -f$1-%g-6 12|date -f-|grep -c ^F;}

f 2013
2

for i in {2010..2017};do echo $i $(f $i) ;done
2010 1
2011 1
2012 3
2013 2
2014 1
2015 3
2016 1
2017 2

Bonus: +78 -> 121

From there, if my function become:

f(){ o=();for t in $(seq -f$1-%g-6 12|date -f- +%a,%b);do [ "${t:0:1}" = "F" ]&&o+=(${t#*,});done;echo ${#o[@]} ${o[@]};}

or

f(){ o=();
     for t in $(seq -f$1-%g-6 1 12|date -f- +%a,%b);do
         [ "${t:0:1}" = "F" ]&&o+=(${t#*,})
       done
     echo ${#o[@]} ${o[@]}
}

for i in {2010..2017};do echo $i $(f $i) ;done
2010 1 Aug
2011 1 May
2012 3 Jan Apr Jul
2013 2 Sep Dec
2014 1 Jun
2015 3 Feb Mar Nov
2016 1 May
2017 2 Jan Oct

Scala 3, 107 bytes

Golfed version. Attempt This Online!

y=>(1 to 12).map{m=>if(java.time.LocalDate.of(y,m,6).getDayOfWeek==java.time.DayOfWeek.FRIDAY)1 else 0}.sum

Ungolfed version. Attempt This Online!

import java.time._

object Main {
  def main(args: Array[String]): Unit = {
    println(countFridays(1776))
    println(countFridays(2012))
    println(countFridays(2013))
    println(countFridays(2014))
  }

  def countFridays(year: Int): Int = {
    (1 to 12).map { month =>
      val firstDay = LocalDate.of(year, month, 6).getDayOfWeek
      if (firstDay == DayOfWeek.FRIDAY) 1 else 0
    }.sum
  }
}

Lua, 95 bytes

n=0 for i=1,12 do n=os.date('%w',os.time{month=i,day=13,year=...})=='5'and n+1or n end print(n)

Try it online!

C, 76 bytes

A function that accepts a year and returns the count of Fridays the 13th for that year:

d(y){return(y+y/4-y/100+y/400)%7;}f(y){return(22>>d(y)&1|2)-(55>>d(y-1)&1);}

If a full program is really required, it comes in at 111 bytes, accepting a single argument and printing to standard out:

d(y){return(y+y/4-y/100+y/400)%7;}main(y,v)char**v;{y=atoi(*++v);putchar('0'+(22>>d(y)&1|2)-(55>>d(y-1)&1));}

Explanation

int day_index(int year)
{
    return (year + year/4 - year/100 + year/400) % 7;
}
int f(int year)
{
    const char a[] = "2332322";
    const char b[] = "1110110";
    return a[day_index(year)]
        -  b[day_index(year-1)];
}

We split the year into two parts (Jan-Feb and Mar-Dec) so that leap years don't disrupt the calculation.

The helper function computes the weekday of New Year's Eve (0 = Sunday). We first use this to determine (in a) how many Fridays the 13th are in March-December. Then we use the weekday index of the preceding year to get the count from b for January and February.

The golfed code uses a bit mask rather than a character array: a becomes 22 and b becomes 55.

Demo

The demo is on Try It Online.

#include <stdio.h>
int main(void)
{
    for (int year = 1990;  year < 2050;  ++year) {
        printf("%d: %d\n", year, f(year));
    }
}
1990: 2
1991: 2
1992: 2
1993: 1
1994: 1
1995: 2
1996: 2
1997: 1
1998: 3
1999: 1
2000: 1
2001: 2
2002: 2
2003: 1
2004: 2
2005: 1
2006: 2
2007: 2
2008: 1
2009: 3
2010: 1
2011: 1
2012: 3
2013: 2
2014: 1
2015: 3
2016: 1
2017: 2
2018: 2
2019: 2
2020: 2
2021: 1
2022: 1
2023: 2
2024: 2
2025: 1
2026: 3
2027: 1
2028: 1
2029: 2
2030: 2
2031: 1
2032: 2
2033: 1
2034: 2
2035: 2
2036: 1
2037: 3
2038: 1
2039: 1
2040: 3
2041: 2
2042: 1
2043: 3
2044: 1
2045: 2
2046: 2
2047: 2
2048: 2
2049: 1

PHP, no builtins, 81 bytes

echo 0x5da5aa76d7699a>>(($y=$argn%400)+($y>102?$y>198?$y>299?48:32:16:0))%28*2&3;

Run with echo <year> | php -nR '<code>'.

breakdown

Weekdays repeat every 400 years.
In the results for 1600 to 1999 (for example), there is a 28-length period with just three gaps:

  0:2212122131132131222211221311
 28:2212122131132131222211221311
 56:2212122131132131222211221311
 84:2212122131132131122
103:       131132131222211221311
124:2212122131132131222211221311
152:2212122131132131222211221311
180:2212122131132131222
199:       131132131222211221311
220:2212122131132131222211221311
248:2212122131132131222211221311
276:221212213113213122221122
300:            2131222211221311
316:2212122131132131222211221311
344:2212122131132131222211221311
372:2212122131132131222211221311

After adjusting the year for these gaps, we can get the result with a simple hash:

$y=$argn%400;foreach([300,199,103]as$k)$y<$k?:$y+=16;
echo"2212122131132131222211221311"[$y%28];

Not short (95 bytes) but pretty. And we can golf

PHP, 55 bytes

for(;++$i<13;)$c+=!date(w,strtotime($argn.-$i));echo$c;

Run with echo <year> | php -nR '<code>'.

Basically the same that Oleg tried and Damir Kasipovic did, just with better golfing:
Every month that starts with a sunday, has a Friday the 13th.
So I loop through the months and count the first days that are sundays.

breakdown

for(;++$i<13;)          // loop $i from 1 to 12
    $c+=!                   // 4. if result is not truthy (weekday==0), increment $c
        date(w,             // 3. get weekday (0 stands for Sunday)
            strtotime(      // 2. convert to timestamp (midnight 1st day of the month)
                $argn.-$i   // 1. concatenate year, "-" and month
            )
        )
    ;
echo$c;                 // output

Clojure, 207 187 bytes

-20 bytes by getting rid of the import, and some whitespace I missed.

(import '[java.time LocalDate DayOfWeek])#(loop[d(LocalDate/parse(str %"-01-01"))c 0](if(=(.getYear d)%)(recur(.plusDays d 1)(if(and(=(.getDayOfMonth d)13)(= (.getDayOfWeek d) DayOfWeek/FRIDAY))(inc c)c))c))

Starting on Janauary 1st of the given year, it loops over each day. If the day is Friday the 13th, it increments the count. It continues to loop until it reaches the next year.

(import '[java.time LocalDate DayOfWeek])

(defn count-friday-13ths [year]
  (loop [d (LocalDate/parse (str year "-01-01")) ; Starting date
         c 0] ; The count
    (if (= (.getYear d) year) ; If we haven't moved onto the next year...
      (recur (.plusDays d 1) ; Add a day...
             (if (and (= (.getDayOfMonth d) 13) ; And increment the count if it's Friday the 13th
                      (= (.getDayOfWeek d) DayOfWeek/FRIDAY))
               (inc c) c))
      c))) ; Return the count once we've started the next year.

APL (Dyalog APL) with cal from dfns, 29 bytes

+/{13∊⍎,⍉3↑¯5↑⍉2↓cal⍵}¨⎕,¨⍳12

Try it online!

⍳ 12 the integers one through twelve

⎕ ,¨ take numeric input and prepend to each of the twelve numbers

{ on each of the pairs, apply the function…

cal⍵ get a calendar for that year-month

2 ↓ drop two rows (caption and days)

 transpose (so we can address columns instead of rows)

¯5 ↑ take the last five (two digits for each of Friday and Saturday plus one space)

3 ↑ take the first two (two digits for Friday plus a space)

 transpose (so we get reading order)

, ravel

 execute as APL expression (gives list of Fridays' dates)

13 ∊ is thirteen a member of that list?

+/ sum the 12 Booleans


Using @Wrzlprmft's algorithm, we can do it without libraries for 53 bytes:

'21232211321211'⊃⍨14|2 3 ¯1+.×⊢,0≠.=400 100 4∘.|-∘0 1

-∘0 1 subtract zero and one

400 100 4 ∘.| division remainder table for the two years (across) divided by these numbers (down)

0 ≠.= inner "product" with 0, but using ≠ and = instead of +.×

⊢ , prepend the unmodified argument year

2 3 ¯1 +.× inner product with these numbers

14 | division remainder when divided by fourteen

'21232211321211' ⌷⍨ index into this string

Perl 6, 55 53

{sum (1..12).map: {Date.new($_,$^a,1).day-of-week>6}}

Old answer:

{sum (1..12).map: {Date.new($_,$^a,13).day-of-week==5}}

Not using any libraries or built-in date functions:

Golfscript – 51

~..({4/.25/.4/--@}2*2*\3*+-
14%' [3/=RI[)a%:*.'\=5%

' [3/=RI[)a%:*.' could as well be 'feefefgeeffgfe'

Python – 82 79

Essentially the same algorithm.

l=lambda y:y/4-y/100+y/400
i=input()
print"21232211321211"[(2*i+3*l(i)-l(i-1))%14]

Using this trick, this can be golfed down further to:

l=lambda y:y/4-y/100+y/400
i=input()
print 94067430>>(4*i+6*l(i)-2*l(i-1))%28&3

This exploits the fact that, calender-wise, there are only 14 different years, which are distinguishable by their last day and whether they are leaping. l calculates the number of leap years up to its argument (if the Gregorian calendar extended backwards to the year 1). (2*i+3*l(i)-l(i-1))%14 is short for l(i)-l(i-1)+(i+l(i))%7*2, where l(i)-l(i-1) tells us whether the argument is a leap year and i+l(i) sums up the shifts of the last day (one in a normal year, two in a leap year).

Python 195 / 204

Works only for previous years, because monthdatescalendar returns a calendar for the given year until now. I think there is a lot of optimizing potential left :).

import calendar, sys
c=calendar.Calendar()
f=0
for m in range(1,12):
 for w in c.monthdatescalendar(int(sys.argv[1]),m):
  for d in w:
   if d.weekday() == 4 and d.day == 13:
    f=f+1
print(f)

Another solution, works for every date but it isn't smaller:

import datetime,sys
y=int(sys.argv[1])
n=datetime.date
f=n(y,1,1)
l=n(y,12,31)
i=0
for o in range(f.toordinal(), l.toordinal()):
 d=f.fromordinal(o)
 if d.day == 13 and d.weekday() == 4:
  i=i+1
print(i)

Common Lisp (CLISP), 149

(print 
    (loop for i from 1 to 12 count 
        (= 4 (nth-value 6 
            (decode-universal-time
                (encode-universal-time 0 0 0 13 i
                    (parse-integer (car *args*)) 0))))))

JavaScript, 70

f=function(a){b=0;for(c=12;c--;)b+=!new Date(a,c,1).getDay();return b}

Python2.7 90 86

from datetime import*
s=c=0
exec's+=1;c+=date(%d,s,9).weekday()<1;'%input()*12
print c

Monday the 9th may not have quite the same ring to it but works just as well.

Edit: A year and a half to notice that date is shorter than datetime :)

Scala, 76 68 characters

In 78 chars:

def f(y:Int)=0 to 11 count(new java.util.GregorianCalendar(y,_,6).get(7)==6)

Nothing out of ordinary, except for using magical numbers for DAY_OF_WEEK = 7 and FRIDAY = 6.

68 character version:

def f(y:Int)=0 to 11 count(new java.util.Date(y-1900,_,6).getDay==5)

Yes, Java changed values of day of the week constants between API's.

C++ - Too many bytes :(

I tried a solution which doesn't make use of any date libraries.

I found a pretty cool (if I may say so myself) solution. Unfortunately I can't get it shorter than this, which really bugs me because it feels like there should be a better way.

The solution hinges on this algorithm which is only 44 bytes in itself. Unfortunately I need another 100 bytes to wrap it nicely...

#include<stdlib.h>
main(int,char**v){int f=0,d,m,y;for(m=1;m<13;++m)d=13,y=atoi(v[1]),(d+=m<3?y--:y-2,23*m/9+d+4+y/4-y/100+y/400)%7-5||++f;return f;}

Output through the return code (in C++, using cout or printf or anything like that requires another #include, which would blow up the solution even more).

Driver / test program:

# Make sure we're not running an old version
rm doomsday.exe

gcc doomsday.cpp -o doomsday.exe

./doomsday.exe 1776
echo 1766: $?

./doomsday.exe 2012
echo 2013: $?

./doomsday.exe 2013
echo 2013: $?

./doomsday.exe 2014
echo 2014: $?

echo `wc doomsday.cpp -c` characters

Output of the driver program:

$ ./test_doomsday 
1766: 2
2013: 3
2013: 2
2014: 1
150 doomsday.cpp characters

Bash and Sed, 39

ncal $1|sed '/F/s/13/\
/g'|grep -c ^\ 2

ncal prints a calendar for the given year with days of the week down the left.

sed with a /g flag subs out all 13s with newlines

grep -c counts the lines that start with " 2" (20 always follows 13)

Thanks to @DigitalTrauma for finding a bug in my old version and proposing a solution!

Rebol, 63

f: 0 repeat m 12[d: do ajoin["6-"m"-"y]if d/weekday = 5[++ f]]f

Usage example in Rebol console:

>> y: 2012
== 2012

>> f: 0 repeat m 12[d: do ajoin["6-"m"-"y]if d/weekday = 5[++ f]]f
== 3

Alternative solution which collects all the Friday 13th in given year is:

>> collect[repeat m 12[d: do ajoin["13-"m"-"y]if d/weekday = 5[keep d]]]
== [13-Jan-2012 13-Apr-2012 13-Jul-2012]

PHP, 82

<?for($i=1,$c=0;$i<13;$i++)$c+=(date("N",mktime(0,0,0,$i,1,$argv[1]))==7);echo $c;

Based on

"Any month that starts on a Sunday contains a Friday the 13th, and there is at least one Friday the 13th in every calendar year."

From http://en.wikipedia.org/wiki/Friday_the_13th

In Smalltalk (Squeak/Pharo flavour), implement this method in Integer (86 chars)

countFriday13^(1to:12)count:[:m|(Date year:self month:m day:13)dayOfWeekName='Friday']

Then use it like this: 2014countFriday13.

Of course, we could use a shorter name, but then it would not be Smalltalk

C# 110 101 93 92

int f(int y){int c=0;for(int i=1;i<13;i++)c+=new DateTime(y,i,8).DayOfWeek>0?0:1;return c;}

C# Linq 88

int g(int y){return Enumerable.Range(1,12).Count(m=>new DateTime(y,m,8).DayOfWeek==0);}

Thanks to Jeppe Stig Nielsen for linq and suggestion of checking for sunday on the 8th.

Thanks to Danko Durbić for suggesting > instead of ==.

Bash (52 47 characters)

for m in {1..12};do cal $m $Y;done|grep -c ^15

C (151 145 137 131 130 chars)

I am surprised to see that there is only one other solution that doesn't use built-in calendar tools. Here is a (highly obfuscated) mathematical approach, also in C:

f(x){return(x+(x+3)/4-(x+99)/100+!!x)%7;}main(int x,char**v){int y=atoi(v[1])%400,a=f(y+1);putchar('1'+((f(y)&3)==1)+(a>2&&a-5));}

(The above compiles in GCC with no errors)

Alternative solution: C (287->215 chars)

I rather enjoyed Williham Totland's solution and his use of compression. I fixed two small bugs and tweaked the code to shorten its length:

main(int x,char**v){char p[400],*a[]={"1221212213113","213122221122131","12213113","22213113","22221122","2131"},*b="abababafcbababafdbababafebababab";*p=0;for(;*b;b++)strcat(p,a[*b-97]);putchar(p[atoi(v[1])%400]);}

Powershell, 68 63 58 52 50

Thanks Iszi for the tip.

$n=$args;(1..12|?{!+(date $n-$_).DayOfWeek}).Count

Using the fact that if the 1st day in the month is Sunday, the 13th will be Friday.

I've also tried:

(1..12|?{!+(date $args-$_).DayOfWeek}).Count

but it's not the same $args inside the script block.

K, 42

{+/1={x-7*x div 7}"D"$"."/:'$+(x;1+!12;1)}

.

k){+/1={x-7*x div 7}"D"$"."/:'$+(x;1+!12;1)}'1776 2012 2013 2014
2 3 2 1

Mathematica 49 46 45 44 42

As a pure function: 42 chars

DayName@{#,m,6}~Table~{m,12}~Count~Friday&

Example

DayName@{#,m,6}~Table~{m,12}~Count~Friday&[2013]

2


As a named function: 44 chars

f=DayName@{#,m,6}~Table~{m,12}~Count~Friday&

Examples

f[1776]
f[2012]
f[2013]
f[2014]

2
3
2
1

Perl + lib POSIX 55

With the idea of not looking for 13th but first, and as sunday is 0 this let save 3 chars! Thanks @ Iszi and Danko Durbić!

$==$_;$_=grep{!strftime"%w",0,0,0,1,$_,$=-1900}(0..11)

Could compute 2010 to 2017 (for sample) in this way:

perl -MPOSIX -pE '$==$_;$_=grep{!strftime"%w",0,0,0,1,$_,$=-1900}(0..11)' <(
    printf "%s\n" {2010..2017})
11321312

(Ok, there is no newline, but that was not asked;)

Old post: 63

$==grep{5==strftime"%w",0,0,0,13,$_,$ARGV[0]-1900}(0..11);say$=

In action:

for i in {2010..2017};do
    echo $i $(
        perl -MPOSIX -E '
            $==grep{5==strftime"%w",0,0,0,13,$_,$ARGV[0]-1900}(0..11);say$=
            ' $i );
  done
2010 1
2011 1
2012 3
2013 2
2014 1
2015 3
2016 1
2017 2

k

64 characters

{+/6={x-7*x div 7}(.:')x,/:(".",'"0"^-2$'$:1+!:12),\:".13"}[0:0]

Reads from stdin

Python(v2) 120

import datetime as d,sys
s=0
for m in range(1, 13):
    if d.datetime(int(sys.argv[1]),m,6).weekday()==4: s=s+1
print s

C 301+ 287

main(int x,char**v){char p[400],*a[]={"abbababbacaacbac","bacabbb","baabbaca","abbb","aabbacaac","abbbbcaac","abbbbaabb"},*b="adcadcadcaebcadcadcafbcadcadcagbcadcadcadc";int c=0,i,y=atoi(v[0]);for(i=0;i<42;i++)strcpy(&p[c],a[b[i]-'a']),c+=strlen(a[b[i]-'a']);printf("%d",p[y%400]-'`');}

Not the shortest answer, but uses no libraries.

R 76 72 57

sum(format(as.Date(paste(scan(),1:12,1,sep="-")),"%w")<1)

Ruby, 49 48 47 46

f=->m{(1..12).count{|i|Time.gm(m,i,6).friday?}}

Edit: Shaved a character by going back a week, thanks to Jan, and another by switching from Time.new to Time.gm

Edit: At the expense of obfuscating it a bit more, I can get to 46 with

f=->m{(1..12).count{|i|Time.gm(m,i,8).wday<1}}