// Divides all the messages per day
Divides all the messages per day
// Divides all the messages per day
func (VS *Server) orderMessagesPerDay(a []Message) [][]Message {
	var messages [][]Message
	previousDayAudit := time.Unix(a[0].Date, 0).Day()
	var aux []Message
	for i := 0; i < len(a); i++ {
		if previousDayAudit != time.Unix(a[i].Date, 0).Day() {
			previousDayAudit = time.Unix(a[i].Date, 0).Day()
			messages = append(messages, aux)
			aux = nil
		}
		aux = append(aux, a[i])
	}
	messages = append(messages, aux)
	return messages
}
func ( VS * Server ) orderMessagesPerDay ( a [ ] Message ) [ ] [ ] Message { var messages [ ] [ ] Message previousDayAudit := time . Unix ( a [ 0 ] . Date , 0 ) . Day ( ) var aux [ ] Message for i := 0 ; i < len ( a ) ; i ++ { if previousDayAudit != time . Unix ( a [ i ] . Date , 0 ) . Day ( ) { previousDayAudit = time . Unix ( a [ i ] . Date , 0 ) . Day ( ) messages = append ( messages , aux ) aux = nil } aux = append ( aux , a [ i ] ) } messages = append ( messages , aux ) return messages }
Divides all the messages per day
Divides all the messages per day
// If the date is different than the previous one, we change the index in the slice // This one is for adding the last loop