define(
        getUserLocale
        parseDateString
        fromEpoch
        transformDate
        transformTime
        transformDateTime
        transformDateTimeLong
        transformDateTimeShort
        transformDecimal
        toGMT
        fromGMT
        transformNumber
define(

class l10n
description Localisation related functions for general page content, widget content and UI elements This should only hold functions which are used across multiple pages, and does not constitute functionality related to a single area/page
namespace Language localisation


getUserLocale : function() {

Get the current logged in user's locale
return {String} The user's locale string in XXX format


parseDateString : function(dateString, meData) {

Parse a date string into a date object and adjust that date to the timezone set by the current user.
param {Object} dateString date to parse in the format 2010-10-06T14:45:54+01:00
param {Object} meData the data from sakai.api.User.data.me


fromEpoch : function(dateString, meData) {

Determines date from an epoch string in UTC and returns a date object and adjust that date to the timezone set by the current user.
param {Object} dateString date epoch
param {Object} meData the data from sakai.api.User.data.me


transformDate : function(date) {

Function that will take in a date object and will transform that date object into a date only string
param {Date} date JavaScript date object that we would like to transform in a date string
return {String} Localized formatted date string


transformTime : function(date) {

Function that will take in a date object and will transform that date object into a time only string
param {Date} date JavaScript date object that we would like to transform in a time string
return {String} Localized formatted time string


transformDateTime : function(date) {

Function that will take in a date object and will transform that date object into a date and time string
param {Date} date JavaScript date object that we would like to transform in a date and time string
return {String} Localized fomatted date and time string


transformDateTimeLong : function(date) {

Function to transform a date into a long date time string eg. Saturday, November 20, 2010 (for en_US)
param {Date} date
return {String} localized string


transformDateTimeShort : function(date) {

Function to transform a date into a short date time string eg. 11/20/2010 5:12 PM (for en_US)
param {Date} date
return {String} localized string


transformDecimal : function(num, decimalplaces) {

Function to localize a number including decimal places
param {Number} num a number
param {Integer} decimalplaces the number of decimal places to use
return {Number} the number formatted


toGMT : function(date, meData) {

Function that will take in a date object and will transform that date object into a GMT date object. This should always be done before we try to save a date back to a file or the database. The timezone we are currently in will be determined from our timezone set in the personal preferences page
param {Date} date JavaScript date object that we would like to transform in a GMT date object
param {Object} meData the data from sakai.api.User.data.me
return {Date} Date object, that will have transformed the given date and time into GMT date and time


fromGMT : function(date, meData) {

Function that will take in a GMT date object and will transform that date object into a local date object. This should always be done after we load a date back from a file or the database. The timezone we are currently in will be determined from our timezone set in the personal preferences page
param {Date} date JavaScript GMT date object that we would like to transform to a local date object
param {Object} meData the data from sakai.api.User.data.me
return {Date} Date object, that will have transformed the given GMT date and time into a local date and time


transformNumber : function(number) {

Function that will take in a JavaScript Number and will transform it into a localised number string that complies with decimal points and character used as separator as specified in the config file
param {Number} number Number we want to localise (eg 10000000.442)
return {String} Localised string of the number given to this function(eg '10.000.000,442')