Permalink
Browse files

Now respecting VALUE=DATE on DATETIME fields

  • Loading branch information...
1 parent 360bb7b commit 1c8d63d60561a61d67510fec03df19beffcb2e60 @james-emerton james-emerton committed Feb 9, 2012
Showing with 5 additions and 5 deletions.
  1. +1 −1 lib/base.js
  2. +4 −4 lib/types.js
View
@@ -194,7 +194,7 @@ CalendarProperty.prototype.setParameter = function(param, value) {
}
CalendarProperty.prototype.format = function() {
- var data = new Buffer(this.name+':'+format_value(this.type, this.value));
+ var data = new Buffer(this.name+':'+format_value(this.type, this.value, this.parameters));
var pos = 0, len;
var output = [];
while(true) {
View
@@ -73,11 +73,11 @@ var _types = {
'DATE-TIME': {
// YYYYMMDDTHHMMSS
// TODO: Support local time with TZID values
- format: function(value) {
+ format: function(value, parameters) {
if(!(value instanceof Date))
value = new Date(value);
- if(value.date_only)
+ if(value.date_only || parameters['VALUE'] === 'DATE')
return format_value('DATE', value);
return value.getUTCFullYear()
@@ -207,15 +207,15 @@ var _types = {
};
-var format_value = exports.format_value = function(type, value) {
+var format_value = exports.format_value = function(type, value, parameters) {
if(value === undefined)
return '';
var fmt = _types[type || 'TEXT'];
if(fmt === undefined)
throw Error("Invalid iCalendar datatype: "+type);
- return fmt.format(value);
+ return fmt.format(value, parameters || {});
}
var parse_value = exports.parse_value = function(type, value, parameters, calendar) {

0 comments on commit 1c8d63d

Please sign in to comment.