Get Name of a Day

From NSIS Wiki
Jump to navigationJump to search
Author: acnweb (talk, contrib)


The Script

 ; GetDayName
 ; Written by Stefan Meinecke
 ;
 ; This function get the name of day for the specified date.
 ; Parameters: [day] [month] [year]
 ; Results:    [day_name]
 
Function GetDayName
  Pop $0 ;day
  Pop $1 ;mon
  Pop $2 ;year
  IntOp $3 $2 / 100
  IntFmt $3 "%u" $3
  IntOp $3 $3 * 100
  IntOp $9 $2 - $3
 
  IntOp $3 $0 % 7
  IntCmp $1 1 mon1or2 w1
  IntCmp $1 2 mon1or2 w1
 
  mon1or2:
    IntOp $4 $9 % 4
    IntCmp $4 4 mon1or2_check1
    IntOp $4 $9 % 400
    IntCmp $4 0 mon1or2_check2
  goto w1
  mon1or2_check1:
    IntOp $4 $9 % 100
    IntCmp $4 0 w1 mon1or2_check2 mon1or2_check2
  goto w1
  mon1or2_check2:
    IntOp $1 $1 + 12
  goto w1
  w1:
 
  # Tabelle 1
  IntOp $5 0 + 0
  IntCmp $1 5 w1_5
  IntCmp $1 6 w1_6
  IntCmp $1 1 w1_10
  IntCmp $1 10 w1_10
  IntCmp $1 2 w1_11
  IntCmp $1 3 w1_11
  IntCmp $1 11 w1_11
  IntCmp $1 9 w1_12
  IntCmp $1 12 w1_12
  IntCmp $1 4 w1_13
  IntCmp $1 7 w1_13
  IntCmp $1 13 w1_13
  IntCmp $1 8 w1_14
  IntCmp $1 14 w1_14
  goto w2
  w1_5:
       IntOp $5 0 + 6
       goto w2
  w1_6:
       IntOp $5 0 + 2
       goto w2
  w1_10:
       IntOp $5 0 + 5
       goto w2
  w1_11:
       IntOp $5 0 + 1
       goto w2
  w1_12:
       IntOp $5 0 + 3
       goto w2
  w1_13:
       IntOp $5 0 + 4
       goto w2
  w1_14:
       IntOp $5 0 + 0
       goto w2
 
  w2:
  IntCmp $1 12 w3 w3 w2_1
 
  w2_1:
     IntOp $1 $1 - 12
     goto w3
  w3:
 
  IntOp $6 $3 + $5
  IntOp $6 $6 % 7
 
#  // Tabelle 2
 
  IntOp $7 1.25 * $9
  IntFmt $8 "%u" $7
  IntOp $9 $7 - $8
 
  IntCmp $7 0.5 w3_2 w3_1 w3_2
  w3_1:
    IntOp $7 $8 + 0
    goto w4
  w3_2:
    IntOp $7 $8 + 1
    goto w4
  w4:
    IntOp $7 $7 % 7
    IntOp $3 $2 / 100
    IntFmt $3 "%u" $3
    IntOp $3 $3 - 1
    IntOp $8 $3 % 4
    IntOp $8 $8 + 1
    IntCmp $8 4 w4_1 w4_2 w4_2
  w4_1:
    Push 2
    Pop $9
    goto w5
  w4_2:
    IntOp $9 2 * $8
    IntOp $9 9 - $9
    goto w5
 w5:
 
  IntOp $8 $9 + $7
  IntOp $5 $8 + $6
  IntOp $5 $5 % 7
 
  IntCmp $5 0 d_sat
  IntCmp $5 1 d_sun
  IntCmp $5 2 d_mon
  IntCmp $5 3 d_tue
  IntCmp $5 4 d_wed
  IntCmp $5 5 d_thu
  IntCmp $5 6 d_fri
  MessageBox MB_OK "fucking bullshit happened! i can't get the Day ?!"
 
  d_sat:
  Push "Sat"
  goto end
 
  d_sun:
  Push "Sun"
  goto end
 
  d_mon:
  Push "Mon"
  goto end
 
  d_tue:
  Push "Tue"
  goto end
 
  d_wed:
  Push "Wed"
  goto end
 
  d_thu:
  Push "Thu"
  goto end
 
  d_fri:
  Push "Fri"
  goto end
 
end:
FunctionEnd