Sha256: 9d995457de1343cedfba2770724666b2ed5ce15544b5f8622d10ebaf94537316

Contents?: true

Size: 741 Bytes

Versions: 1

Compression:

Stored size: 741 Bytes

Contents

root = exports ? this

class root.Utils
	formatRestTime: (milliseconds) ->
		seconds = milliseconds / 1000

		# Calc minutes
		minutes = Math.floor(seconds / 60)
		seconds -= minutes * 60
		seconds = Math.floor(seconds)

		# Calc hours
		hours = Math.floor(minutes / 60)
		minutes -= hours * 60

		# Add zeros to seconds if needed
		seconds = "0#{seconds}" if seconds < 10
		minutes = "0#{minutes}" if minutes < 10

		"#{hours}:#{minutes}:#{seconds}" if hours > 0
		"#{minutes}:#{seconds}"

	formatNumber: (number) ->
		number += ''
		x = number.split('.')
		x1 = x[0]
		x2 = if x.length > 1 then ',' + x[1] else ''
		rgx = /(\d+)(\d{3})/

		while rgx.test(x1)
			x1 = x1.replace(rgx, '$1' + "." + "$2")

		x1 + x2

root.utils = new Utils()

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
onlinegames_info_connect-0.0.1 app/assets/javascripts/onlinegames_info_connect/utils.js.coffee