Last active
August 27, 2016 15:25
-
-
Save GioRosso/246b3f7d9c1125a2c603e1addfd7660b to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="form-group"> | |
<%= unos.label "Početak (HH:MM)" %> | |
<%= unos.text_field :begintime, class: 'form-control', value: Time.now.strftime('%H:%M') %> | |
</div> | |
<div class="form-group"> | |
<%= unos.label "Kraj (HH:MM)" %> | |
<%= unos.text_field :endtime, class: 'form-control' %> | |
</div> | |
<script> | |
$(document).ready(function(){ | |
$("#record_difftime").click(function(){ | |
var starttime = $("#record_begintime").val(); | |
var finishtime = $("#record_endtime").val(); | |
var st_cut = starttime.split(':') | |
var et_cut = finishtime.split(':') | |
var sahat1 = parseInt(st_cut[0]); | |
var minut1 = parseInt(st_cut[1]); | |
var sahat2 = parseInt(et_cut[0]); | |
var minut2 = parseInt(et_cut[1]); | |
if (sahat2 > sahat1){ | |
if (sahat2-sahat1 == 1) | |
min_total = (60-minut1) + minut2; | |
else { | |
min_total = (60-minut1) + minut2 + ((sahat2-sahat1-1)*60); | |
} | |
} else if (sahat2 == sahat1) { | |
if (minut2 > minut1){ | |
// primjer 16:15 - 16:56 | |
min_total = minut2 - minut1; | |
} else { | |
min_total = 1440 - (minut1 - minut2); | |
// !!! radni obim od skoro 24h... ??? | |
} | |
} else { | |
min_total = ((24-sahat1)*60-minut1) + ((sahat2*60)+minut2); | |
} | |
$("#record_difftime").val(min_total); | |
}); | |
}); | |
</script> | |
<button type="button" class="btn btn-danger" id="runner" style="display:none;">Danger</button> | |
<div class="form-group"> | |
<%= unos.label "Prije - isto - kasnije?" %> | |
<%= unos.text_field :difftime, class: "form-control text-center time-diff-display", readonly: true, value: '000' %> | |
</div> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment