Update change log and spec for wrt-plugins-tizen_0.4.25-1
[platform/framework/web/wrt-plugins-tizen.git] / src / Calendar / JSCalendarItemProperties.cpp
index 7f2cca0..20bad95 100755 (executable)
@@ -806,16 +806,28 @@ JSValueRef JSCalendarItemProperties::getPropertyDuration(JSContextRef context,
     Try
     {
         CalendarEventPtr item = getPrivateObject(object);
+        TimeUtilConverter converter(context);
+
+               DurationProperties duration;
+               if(UNDEFINED_TIME!=item->getDuration()->length) {
+                       duration.length = item->getDuration()->length;
+                       duration.unit = item->getDuration()->unit;
+                       LoggerD("Duration length: "<<duration.length<<", unit: "<<duration.unit);
+                       return converter.makeDurationObject( duration );
+               }
 
+               // Alternatively generate the duration object using start/end time.
                if(UNDEFINED_TIME==item->getStartTime() || UNDEFINED_TIME==item->getEndTime()) {
                        LoggerD("Start or end time is not defined.");
                    return JSValueMakeUndefined(context);
                }
 
-        TimeUtilConverter converter(context);
         long long length = item->getEndTime() - item->getStartTime(); // in seconds only
         LoggerD("item->getStartTime():"<< item->getStartTime() << ", length:" << length);
-        return converter.makeMillisecondDurationObject( length*1000 );
+               duration.length = length;
+               duration.unit = SECONDS_UNIT;
+
+        return converter.makeDurationObject( duration );
     }
     Catch(Exception)
     {
@@ -855,6 +867,9 @@ bool JSCalendarItemProperties::setPropertyDuration(JSContextRef context,
             return false;
         }
 
+               event->getDuration()->length = length;
+               event->getDuration()->unit = unit;
+
         return true;
     }
     Catch(Exception)