package cn.socialclock.manager;

import java.util.Calendar;

import cn.socialclock.model.AlarmEvent;
import cn.socialclock.utils.DatetimeFormatter;

/**
 * Created by mapler
 * Sns Manager
 * todo
 */
public class SnsManager {

    protected static String buildSnsMessage(AlarmEvent alarmEvent) {

        long snoozePeriodInSeconds = (alarmEvent.getEndAt().getTimeInMillis() -
                alarmEvent.getStartAt().getTimeInMillis()) / 1000;

        String snoozePeriodMessage = ""
                + (snoozePeriodInSeconds / 60 > 0 ? (snoozePeriodInSeconds / 60 + "分") : "")
                + snoozePeriodInSeconds % 60 + "秒";

        String snsMessage = "(这是测试)"
                + "我本来定的"
                + alarmEvent.getStartAt().get(Calendar.HOUR)
                + "点"
                + String.format("%02d", alarmEvent.getStartAt().get(Calendar.MINUTE))
                + "分的闹钟，结果"
                + alarmEvent.getEndAt().get(Calendar.HOUR)
                + "点"
                + String.format("%02d", alarmEvent.getEndAt().get(Calendar.MINUTE))
                + "分才起来。按掉"
                + alarmEvent.getSnoozeTimes() + "次闹铃，赖床" + snoozePeriodMessage
                + "...我果然是个废物。(" + DatetimeFormatter.calendarToString(alarmEvent.getEndAt())
                + ")";

        return snsMessage;
    }
}

@@ -439,16 +439,125 @@
  1000;%0A%0A
+        String snsMessage;%0A        if (snoozePeriodInSeconds %3E 60 %7C%7C alarmEvent.getSnoozeTimes() %3E 0 ) %7B%0A    
         
@@ -588,16 +588,20 @@
 ge = %22%22%0A
+    
         
@@ -679,17 +679,16 @@
  + %22
-%E5%88%86%22) : %22%22)
+ min%22) :
 %0A   
@@ -700,17 +700,19 @@
         
-+
+   
  snoozeP
@@ -738,21 +738,24 @@
  + %22
-%E7%A7%92%22
+ sec%22)
 ;%0A
-%0A
         
 Stri
@@ -742,38 +742,35 @@
  sec%22);%0A        
-String
+   
  snsMessage = %22(
@@ -773,15 +773,20 @@
 = %22(
-%E8%BF%99%E6%98%AF%E6%B5%8B%E8%AF%95)%22%0A
+test) %22%0A    
     
@@ -804,15 +804,23 @@
  + %22
-%E6%88%91%E6%9C%AC%E6%9D%A5%E5%AE%9A%E7%9A%84%22%0A
+Alarm at %22%0A    
     
@@ -884,36 +884,40 @@
                 
+    
 + %22
-%E7%82%B9
+:
 %22%0A              
@@ -910,32 +910,36 @@
                 
+ 
+   
 + String.format(
@@ -1012,20 +1012,33 @@
     
-+ %22%E5%88%86%E7%9A%84%E9%97%B9%E9%92%9F%EF%BC%8C%E7%BB%93%E6%9E%9C%22%0A
+    + %22. Get up at %22%0A    
     
@@ -1112,14 +1112,22 @@
     
+    
 + %22
-%E7%82%B9
+:
 %22%0A
+    
     
@@ -1226,20 +1226,30 @@
     
-+ %22%E5%88%86%E6%89%8D%E8%B5%B7%E6%9D%A5%E3%80%82%E6%8C%89%E6%8E%89%22%0A
+    + %22. Snooze %22%0A    
     
@@ -1296,69 +1296,544 @@
 ) + 
-%22%E6%AC%A1%E9%97%B9%E9%93%83%EF%BC%8C%E8%B5%96%E5%BA%8A%22 + snoozePeriodMessage%0A                + %22...%E6%88%91%E6%9E%9C%E7%84%B6%E6%98%AF%E4%B8%AA%E5%BA%9F%E7%89%A9%E3%80%82
+(alarmEvent.getSnoozeTimes() %3E 1 ? %22 times. %22 : %22 time. %22)%0A                    + %22Late %22 + snoozePeriodMessage%0A                    + %22 (%22 + DatetimeFormatter.calendarToString(alarmEvent.getEndAt())%0A                    + %22)%22;%0A        %7D%0A        else %7B%0A            snsMessage = %22(test) %22%0A                    + %22Alarm and get up at %22%0A                    + alarmEvent.getStartAt().get(Calendar.HOUR)%0A                    + %22:%22%0A                    + String.format(%22%2502d%22, alarmEvent.getStartAt().get(Calendar.MINUTE))%0A                    + %22. 
 (%22 +
@@ -1907,22 +1907,36 @@
         
+    
 + %22)%22;
+%0A        %7D
 %0A%0A      

Translate Chinese