The song "Midnight" was written by Bayruch (Benedict) Shafir in Krakow in 1886. It appears in both Hebrew and Yiddish, on facing pages. The Hebrew version is called "If I forget thee Jerusalem" and the Yiddish version is titled "Midnight".
The song describes the trials of the Jewish people in the diaspora (anti-Semitism, assimilation) and the eternal longing for Jerusalem.
As Shafir points out, the song was set to the melody of "Szumia jodly ag or Szczycie" from the opera "Halka" by Stanisław Moniuszko.
Avigdor HaMeiri later reworked the song and melody in "From the Summit of Mount Scopus."