Skip to content

Instantly share code, notes, and snippets.

@kubadlo
Last active March 1, 2019 16:17
Show Gist options
  • Select an option

  • Save kubadlo/17d82fe7a069bdc7f68ca8c27b84d38e to your computer and use it in GitHub Desktop.

Select an option

Save kubadlo/17d82fe7a069bdc7f68ca8c27b84d38e to your computer and use it in GitHub Desktop.

Revisions

  1. kubadlo revised this gist Mar 1, 2019. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion birth-number.ahk
    Original file line number Diff line number Diff line change
    @@ -7,7 +7,7 @@ GenerateBirthNum()
    Random, Gender, 0, 1

    Year:
    Random, Year, 1920, FormatTime, CurrentDateTime,, yyyy
    Random, Year, 1970, FormatTime, CurrentDateTime,, yyyy
    ShortYear := Mod(Year, 100) < 10 ? 0 . Mod(Year, 100) : Mod(Year, 100)

    Month:
  2. kubadlo revised this gist Mar 1, 2019. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion birth-number.ahk
    Original file line number Diff line number Diff line change
    @@ -30,7 +30,8 @@ GenerateBirthNum()
    Sequence := 0 . Sequence
    }

    ControlNumber := Mod(ShortYear . Month . Day . Sequence, 11)
    BirthNumModulo := Mod(ShortYear . Month . Day . Sequence, 11)
    ControlNumber := BirthNumModulo == 10 ? 0 : BirthNumModulo

    SendInput % ShortYear . Month . Day . "/" . Sequence . ControlNumber
    Exit
  3. kubadlo created this gist Mar 1, 2019.
    57 changes: 57 additions & 0 deletions birth-number.ahk
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,57 @@
    ; Function to generate birth numbers [Win + Shift + B]
    #+b::GenerateBirthNum()

    GenerateBirthNum()
    {
    Gender:
    Random, Gender, 0, 1

    Year:
    Random, Year, 1920, FormatTime, CurrentDateTime,, yyyy
    ShortYear := Mod(Year, 100) < 10 ? 0 . Mod(Year, 100) : Mod(Year, 100)

    Month:
    Random, Month, 1, 12
    Month := Gender == 1 ? Month + 50 : Month
    Month := Month < 10 ? 0 . Month : Month

    Day:
    Random, Day, 1, LastDayOfMonth(Month, Year)
    Day := Day < 10 ? 0 . Day : Day

    Sequence:
    Random, Sequence, 0, 999
    if (Sequence < 10)
    {
    Sequence := 00 . Sequence
    }
    else if (Sequence < 100)
    {
    Sequence := 0 . Sequence
    }

    ControlNumber := Mod(ShortYear . Month . Day . Sequence, 11)

    SendInput % ShortYear . Month . Day . "/" . Sequence . ControlNumber
    Exit
    }

    LastDayOfMonth(Month, Year)
    {
    if (Month == 4 || Month == 6 || Month == 9 || Month == 11)
    {
    return 30
    }

    if (Month == 2)
    {
    return IsLeapYear(Year) ? 29 : 28
    }

    return 31
    }

    IsLeapYear(Year)
    {
    return Mod(Year, 4) == 0 && (Mod(Year, 100) != 0 || Mod(Year, 400) == 0)
    }