[Question]
  [
## Happy birthday to Me!
Write a program that prints `Happy birthday to me!` on its birthday.
1. The program's birthday is the creation, last modification or compilation time of the program (you choose), and must not be hard-coded.
2. The date you use as the birthday must not be affected by the program's invocation or execution in any way. You can't modify your birthday.
3. For extra credit (-15% byte count), print `Happy birthday to you!` on your birthday (hard coded), [if it doesn't coincide](http://xkcd.com/680/) with the program's. Or use some celebrity's birthday and get -14%.
4. It must print only this, and not print anything on any other day.
5. Count bytes, in UTF-8.
6. Use the Gregorian calendar.
Good luck and happy birthday (to the newborn programs).
P.S.  
Following Izkata's comment, if you print `Happy birthday to Mel` on [Mel Kaye](http://www.catb.org/jargon/html/story-of-mel.html)'s birthday, you get 20% off. But you have to provide a credible source that it's this date.
  
[Answer]
# bash - 65
```
[ `date +%d%m -r $0` = `date +%d%m` ]&&echo Happy birthday to me!
```
Thanks to *ugoren*, *ace* and *nyuszika7h* for help.
[Answer]
## PHP ~~77~~ ~~75~~ ~~74~~ ~~65~~ 60
Many thanks to the superb suggestions from [Tim Seguine](https://codegolf.stackexchange.com/questions/21285/happy-birthday-to-me/21294#comment43024_21294):
```
<?date(dm,getlastmod())-date(dm)&&die?>Happy birthday to me!
```
## Sneaky PHP: ~~46~~ ~~42~~ ~~41~~ 40
Using [Phil H's idea](https://codegolf.stackexchange.com/a/21291/4040) and again [Tim Seguine's suggestion](https://codegolf.stackexchange.com/questions/21285/happy-birthday-to-me/21294#comment43024_21294):
```
<?touch(__FILE__)?>Happy birthday to me!
```
[Answer]
# C# 198.05 (233 - 15%)
```
using s=System;class P{static void Main(){string t=s.DateTime.Now.ToString("Mdd"),b="1202";if(s.IO.File.GetCreationTime(typeof(P).Assembly.Location).ToString("Mdd")==t|b==t)s.Console.Write("Happy birthday to "+(b==t?"you!":"me!"));}}
```
Formatted:
```
using s = System;
class P
{
    static void Main()
    {
        string t = s.DateTime.Now.ToString("Mdd"), b = "1202";
        if (s.IO.File.GetCreationTime(typeof(P).Assembly.Location).ToString("Mdd") == t | b == t)
            s.Console.Write("Happy birthday to " + (b == t ? "you!" : "me!"));
    }
}
```
# 191 (No bonus)
```
using s=System;class P{static void Main(){if(s.IO.File.GetCreationTime(typeof(P).Assembly.Location).ToString("Mdd")==s.DateTime.Now.ToString("Mdd"))s.Console.Write("Happy birthday to me!");}}
```
# 181,05 (213 - 15%)
With some additional instructions (you need to compile this to `b.exe` and run it from the directory the executable is in) I can get it down to this:
```
using s=System;class P{static void Main(){string t=s.DateTime.Now.ToString("Mdd"),b="1202";if(s.IO.File.GetCreationTime("b.exe").ToString("Mdd")==t|b==t)s.Console.Write("Happy birthday to "+(b==t?"you!":"me!"));}}
```
# 171 (No bonus)
Same instructions as above, this time only printing a message on it's own birthday (so no -15% bonus).
```
using s=System;class P{static void Main(){if(s.IO.File.GetCreationTime("b.exe").ToString("Mdd")==s.DateTime.Now.ToString("Mdd"))s.Console.Write("Happy birthday to me!");}}
```
[Answer]
# Java - 275 - 15% = 233.75 with bonus / 237 without bonus
With bonus:
```
import java.util.*;class L{public static void main(String[]y){int s=f(new Date());String j="Happy birthday to ";System.out.print(s==f(new Date(new java.io.File("L.class").lastModified()))?j+"me!":s==183?j+"you!":"");}static int f(Date d){return d.getMonth()*40+d.getDate();}}
```
Without the bonus:
```
import java.util.*;class L{public static void main(String[]y){if(f(new Date())==f(new Date(new java.io.File("L.class").lastModified())))System.out.print("Happy birthday to me!");}static int f(Date d){return d.getMonth()*40+d.getDate();}}
```
I was born in April, 23rd.
[Answer]
## Matlab: 66
```
t=dir('f.m');if strncmp(t.date,date,5),'Happy birthday to me!',end
```
File name has to be 'f.m'
[Answer]
I'm pretty proud of this little trick to save a few bytes on the message. I hope it will be included in other answers. I was the first to think of this!
# Python
105 characters, no extra credit. Save the file as "happy birthday to me" and run. Runs in GMT only, and "birthday" is defined as the date of your birth, not it's anniversary (also often call "birthday").
```
import sys,os,time
if (int(os.stat(*sys.argv).st_atime/86400)==int(time.time()/86400)):print sys.argv[0]
```
For it to work, save this as "happy birthday to me" and run `python "happy birthday to me"`
Note: of course, the all but a small bootstrap could be in the filename, making any arbitrarily large code reduce down to the bootstrap. Normally I would consider this "cheating". However, "happy birthday to me" is not an unreasonable filename - it describes what the program does, much better than some programs (e.g. "python"), so in this case I'm going to allow it :)
[Answer]
**GNU COBOL** with -free, **204**
```
PROGRAM-ID.B.DATA DIVISION.WORKING-STORAGE SECTION.
1 A PIC XXXX/XX.
1 B PIC X(5).
1 C PIC X(21).
PROCEDURE DIVISION.ACCEPT A FROM DATE
ACCEPT C
MOVE WHEN-COMPILED TO B
IF A(3:5) = B OR "12/09" DISPLAY C.
```
I break the rules about the celebrity, so no bonus there...
The text produced is user-input (requested when run). If that is not good-to-go, then the line defining `C` needs to be deleted, as does `ACCEPT C`, and `DISPLAY C` must become `DISPLAY "HAPPY BIRTHDAY TO ME!"`, for an extra seven characters.
`WHEN-COMPILED` is a special-register containing compile date/time which is available to the program (always handy, you can know you have the correct version). It is truncated in the `MOVE` because the rest isn't needed. `DATE` is the current date - this one is yymmdd.
The `/` in the definition of A is an insertion editing symbol, since the compile-date contains slashes. An extra character, but eases the compare.
[Celebrity = Grace Hopper](http://www.google.com/doodles/grace-hoppers-107th-birthday)
[Answer]
## Batch - 37 Bytes
Stealing the method used by one of the Bash answers..
```
@echo.>>%0&echo Happy birthday to me!
```
**Other method - 145 Bytes**
```
@for /f "tokens=2,3 delims=/ " %%a in ("%date%")do @for /f "tokens=1,2 delims=/" %%c in ("%~t0")do @if %%a%%b==%%c%%d @echo Happy Birthday to me!
```
[Answer]
# Ruby, 69 characters/bytes
```
puts'Happy birthday to me!'if(Time.new-File.atime($0))%31536000<86400
```
`31536000` is the number of seconds in a year, and `86400` is the number of seconds in a day.
[Answer]
# JavaScript
## Node.js, 156 bytes
```
b=new Date(require("fs").statSync(__filename).mtime);d=new Date();b.getDate()==d.getDate()&&b.getMonth()==d.getMonth()&&console.log("Happy birthday to me!")
```
Uses the file's modification time.
[Answer]
# Powershell - 105 bytes
```
if('{0:M}'-f(gi $MyInvocation.MyCommand.Definition).creationtime-eq(date -f M)){'Happy birthday to me!'}
```
Ungolfed:
```
if('{0:M}' -f (gi $MyInvocation.MyCommand.Definition).creationtime -eq (date -f M)){
  'Happy birthday to me!'
}
```
The bonus isn't worth it, I can only get 117.5.
[Answer]
### Powershell - 127
```
if ((gci $MyInvocation.MyCommand.Path).lastwritetime.ToString("MMdd") -eq (get-date).ToString("MMdd")){"happy birthday to me!"}
```
### For the 15% bonus - 151 bytes, less 15% = 128.4
```
$r=@{"0308"="you";(gci $MyInvocation.MyCommand.Path).lastwritetime.ToString("MMdd")="me"}[(get-date).tostring("MMdd")]
if($r){"Happy birthday to $r!"}
```
[Answer]
## Ruby - ~~80~~ ~~103~~ 87 bytes
```
m=File.mtime $0
t=Time.now
puts"Happy birthday to me!"if t.month==m.month&&t.day==m.day
```
---
## Ruby - ~~123~~ ~~115~~ ~~135~~ 121 - 15% = ~~104.55~~ ~~97.75~~ ~~114.75~~ 102.85 points
```
t=Time.now
{me:File.mtime($0),you:Time.at(36e5)}.map{|n,d|puts"Happy birthday to #{n}!"if t.month==d.month&&t.day==d.day}
```
Might be a little longer or shorter depending on where your birthday falls in the year, and the shortest way to represent that. For mine, that's `36e5` (seconds since epoch; time zone dependent).
---
Does Mel **Gibson** count? Here's a 138 byte - 35% bonus = **89.7-point** program that celebrates itself, me, and Mel!
```
t=Time.now
{me:File.mtime($0),you:Time.at(36e5),Mel:Time.at(2e5)}.map{|n,d|puts"Happy birthday to #{n}!"if t.month==d.month&&t.day==d.day}
```
[Answer]
# PureBasic
## Without Bonus - 142
```
If Bool(FormatDate("%dd%mm",Date())=FormatDate("%dd%mm",GetFileDate(ProgramFilename(),0)))
MessageRequester("","Happy birthday To me!")
EndIf
```
## With Bonus - 218 - 15% = 185.3
```
Dim s$(2)
s$(1)="me"
s$(2)="you"
m$="%dd%mm"
d$=FormatDate(m$,Date())
i=Bool(d$=FormatDate(m$,GetFileDate(ProgramFilename(),0)))|(Bool(d$="2301")<<1)
If i=0:End:EndIf
MessageRequester("","Happy birthday To "+s$(i)+"!")
```
[Answer]
## TI-BASIC, 68 bytes
```
If Ans=0:getDate→G:0:G=G:If getDate=G:Disp "HAPPY BIRTHDAY TO ME!"
```
Remember, these tokens are one byte: `If , Ans, →, Disp`. `getDate` is two bytes. All other one-character symbols are one byte.
[Answer]
# J 79
```
 echo((6!:0'')(('',:'Happy birthday to me!'){~])@:-:&(1 2&{)&:>])1{,1!:0{:4!:3''
```
### Bonus version120 - 15% = 102
Do I get extra credit for also printing both when both are having their birthday?
```
echo((2 6$(6!:0 '') , 0 2 7)(' ','Happy birthday to ',"2 1]3 5$'you! me!  both!'){~#.@:(-:&(1 2&{)"1)&:>])1{,1!:0{:4!:3''
```
Explanation (right to left):
```
last =: {:4!:3''     NB. Take the last script run (i.e. the file itself)
time =: 1{,1!:0 last NB. the modification time is the second element in that file's listing
```
The central verb of the [train](http://www.jsoftware.com/help/dictionary/dictf.htm)
```
unbox_both =: &:>      NB. unboxes left and right argument
match  =: -:&(1 2&{)"1 NB. for each date given, left and right, compare them
to_int =: #.           NB. convert boolean to int
from   =: {~           NB. from the left array, take element right.
NB. H contains messages an empty row, appended to all combinations of messages. 
H =: (' ','Happy birthday to ',"2 1]3 5$'you! me!  both!')
V =: (H from to_int)@:match unbox_both NB. after unboxing and comparing, 
                                       NB. select the according message
```
The left tine for the central train:
```
dates=: (2 6$(6!:0 '') , 0 2 7) NB. the current date, and the relevant fields of my birthday.
NB. Combining the bricks:
echo (dates V ]) time           NB. output the monads result on time.
```
[Answer]
# Java - 196
This differs from the other Java submission by using Strings, shaving 41 characters off in the process. It uses String.format("%tj") to format a java.util.Date or a long as a day-of-year String, and then compares these two Strings.
```
class Z{public static void main(String[]y){if("".format("%tj",new java.util.Date()).equals("".format("%tj",new java.io.File("Z.class").lastModified())))System.out.print("Happy birthday to me!");}}
```
Formatted:
```
class Z
{
    public static void main(String[] y)
    {
        if ("".format("%tj", new java.util.Date()).equals("".format("%tj", new java.io.File("Z.class").lastModified())))
            System.out.print("Happy birthday to me!");
    }
}
```
[Answer]
## C# 191 no bonus
```
using s=System;class P{static void Main(){if(s.IO.File.GetCreationTime(typeof(P).Assembly.Location).ToString("Mdd")==s.DateTime.Now.ToString("Mdd"))s.Console.Write("Happy birthday to me!");}}
```
formatted:
```
using s = System;
class P
{
    static void Main()
    {
        if (s.IO.File.GetCreationTime(typeof(P).Assembly.Location).ToString("Mdd") == s.DateTime.Now.ToString("Mdd"))
            s.Console.Write("Happy birthday to me!");
    }
}
```
[Answer]
**JavaScript (node.js) - 100 bytes**
```
(require('fs').fstatSync(4).mtime+1).match(Date().substr(4,6))&&console.log('Happy birthday to me!')
```
[Answer]
**vb.net ~161c**
This will print the celebration message to all whose birthday it is.
```
Module M
Sub Main
For Each b In{({"1705","Alan"}),({"2012","You"}),({FileDateTime(Process.GetCurrentProcess.MainModule.FileName).ToString("ddMM"),"Me"})}
If b(0)=Now.ToString("ddMM") Then Console.WriteLine("Happy Birthday To {0}!",b(1))
Next
End Sub
End Module
```
Alan => Alan Kaye
Score: 253c (-33c vb.net min) = 220 - 15% (my birthday bonus) = 187c - 14% (Celeb Birthday) = 160.82 ~161c or 220c - 29% = 156.2 ~157c
[Answer]
# Powershell, 82 bytes
> 
> see also answers from [Chris J](https://codegolf.stackexchange.com/a/21306/80745) and [SpellingD](https://codegolf.stackexchange.com/a/21431/80745)
> 
> 
> 
```
"Happy birthday to me!"|?{(gv My* -v|% M*|% p*h|gci|% l*w*e|% D*r)-eq(date|% D*r)}
```
where
```
gv My* -v|% M*|% p*h|gci|% l*w*e|% D*r
```
is the combinations of [shortcuts](https://codegolf.stackexchange.com/a/111526/80745) and [aliases](https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_aliases) for the expression:
```
Get-Valiable MyInvocation -value|% MyCommand|% Path|Get-ChildItem|% LastWritetime|% DayOfYear
```
that equivalent a canonical form:
```
(Get-ChildItem $MyInvocation.MyCommand.Path).LastWritetime.DayOfYear
```
---
# Powershell, 119 bytes - 14% = 102.34 Points
```
filter e{$_-eq(date|% D*r)}$('me'|?{gv My* -v|% M*|% p*h|gci|% l*w*e|% D*r|e}
'Prof'|?{3|e})|%{"Happy birthday to $_!"}
```
At [January 3](https://en.wikipedia.org/wiki/J._R._R._Tolkien), the script display `Happy birthday to Prof!`. If this script is saved on January 3, two greetings will be displayed.
]