Beispiel #1
0
        DateTime GetStrictDate(DateTime d, DateGranularity unit)
        {
            switch (unit)
            {
            case DateGranularity.Second:
                return(new DateTime(d.Year, d.Month, d.Day, d.Hour, d.Minute,
                                    d.Second, d.Kind));

            case DateGranularity.Minute:
                return(new DateTime(d.Year, d.Month, d.Day, d.Hour, d.Minute, 0,
                                    d.Kind));

            case DateGranularity.Hour:
                return(new DateTime(d.Year, d.Month, d.Day, d.Hour, 0, 0, d.Kind));

            case DateGranularity.Day:
                return(new DateTime(d.Year, d.Month, d.Day, 0, 0, 0, d.Kind));

            case DateGranularity.Month:
                return(new DateTime(d.Year, d.Month, 1, 0, 0, 0, d.Kind));

            case DateGranularity.Year:
                return(new DateTime(d.Year, 1, 1, 0, 0, 0, d.Kind));

            default:
                throw new NotReachedException();
            }
        }
Beispiel #2
0
        /// <summary>
        /// Initializes the <see cref="DateRange"/> by using the given first,
        /// step type and number of steps per unit.
        /// </summary>
        /// <param name="begin">
        /// The first date of the range.
        /// </param>
        /// <param name="end">
        /// The last date if the range
        /// </param>
        /// <param name="granularity">
        /// The granularity of the step. This represents the number of steps to
        /// advance per item enumerated while enumerating the dates of a range.
        /// </param>
        /// <param name="unit">
        /// The type of the <paramref name="granularity"/>.
        /// </param>
        /// <exception cref="ArgumentOutOfRangeException">
        /// <paramref name="begin"/> is greater than
        /// <paramref name="end"/> - or -
        /// <para>
        /// <paramref name="granularity"/> is negative - or -
        /// </para>
        /// </exception>
        /// <remarks>
        /// The dates of the range is enumerated using
        /// <paramref name="granularity"/> units of
        /// <paramref name="unit"/>.
        /// </remarks>
        public StrictDateRange(DateTime begin, DateTime end, int granularity,
                               DateGranularity unit)
        {
            DateTime begin_strict = GetStrictDate(begin, unit);
            DateTime end_strict   = GetStrictDate(end, unit);

            interval_ = new DateRange(begin_strict, end_strict, granularity, unit);
        }
Beispiel #3
0
        /// <summary>
        /// Initializes the <see cref="DateRange"/> by using the given first,
        /// step type and number of steps per unit.
        /// </summary>
        /// <param name="first_date">
        /// The first date of the range.
        /// </param>
        /// <param name="last_date">
        /// The last date if the range
        /// </param>
        /// <param name="granularity">
        /// The granularity of the step. This represents the number of steps to
        /// advance per item enumerated while enumerating the dates of a range.
        /// </param>
        /// <param name="granularity_unit">
        /// The type of the <paramref name="granularity"/>.
        /// </param>
        /// <exception cref="ArgumentOutOfRangeException">
        /// <paramref name="first_date"/> is greater than
        /// <paramref name="last_date"/> - or -
        /// <para>
        /// <paramref name="granularity"/> is negative - or -
        /// </para>
        /// </exception>
        /// <remarks>
        /// The dates of the range is enumerated using
        /// <paramref name="granularity"/> units of
        /// <paramref name="granularity_unit"/>.
        /// </remarks>
        public DateRange(DateTime first_date, DateTime last_date, int granularity,
                         DateGranularity granularity_unit)
        {
            if (first_date > last_date)
            {
                throw new ArgumentOutOfRangeException("first_date",
                                                      "The first date should be greater than the last date of the range");
            }

            if (granularity < 0)
            {
                throw new ArgumentOutOfRangeException("granularity",
                                                      "The granularity should not be negative");
            }

            first_date_       = first_date;
            last_date_        = last_date;
            granularity_      = granularity;
            granularity_unit_ = granularity_unit;
        }
Beispiel #4
0
        /// <summary>
        /// Set the date the photo was posted (uploaded) and the date the photo was taken.
        /// Changing the date posted will affect the order in which photos are seen in your photostream.
        /// </summary>
        /// <remarks>
        /// All dates are assumed to be GMT. It is the developers responsibility to change dates to the local users
        /// timezone.
        /// </remarks>
        /// <param name="photoId">The id of the photo to set the dates.</param>
        /// <param name="datePosted">The new date to set the date posted too.</param>
        /// <param name="dateTaken">The new date to set the date taken too.</param>
        /// <param name="granularity">The granularity of the date taken.</param>
        /// <returns>True if the dates where updated successfully.</returns>
        public void PhotosSetDates(string photoId, DateTime datePosted, DateTime dateTaken, DateGranularity granularity)
        {
            var parameters = new Dictionary <string, string>();

            parameters.Add("method", "flickr.photos.setDates");
            parameters.Add("photo_id", photoId);
            if (datePosted != DateTime.MinValue)
            {
                parameters.Add("date_posted", UtilityMethods.DateToUnixTimestamp(datePosted).ToString());
            }
            if (dateTaken != DateTime.MinValue)
            {
                parameters.Add("date_taken", dateTaken.ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo));
                parameters.Add("date_taken_granularity", granularity.ToString("d"));
            }

            GetResponseNoCache <NoResponse>(parameters);
        }
Beispiel #5
0
 /// <summary>
 /// Set the date taken for a photo.
 /// </summary>
 /// <remarks>
 /// All dates are assumed to be GMT. It is the developers responsibility to change dates to the local users
 /// timezone.
 /// </remarks>
 /// <param name="photoId">The id of the photo to set the date taken for.</param>
 /// <param name="dateTaken">The date taken.</param>
 /// <param name="granularity">The granularity of the date taken.</param>
 /// <returns>True if the date was updated successfully.</returns>
 public void PhotosSetDates(string photoId, DateTime dateTaken, DateGranularity granularity)
 {
     PhotosSetDates(photoId, DateTime.MinValue, dateTaken, granularity);
 }
Beispiel #6
0
 public GroupingInfo(string name, ColumnSortOrder sortOrder, DateGranularity dateGranularity,
                     string sortAggregate)
 {
     throw new global::System.NotImplementedException("GroupingInfo");
 }
Beispiel #7
0
 public void setDateGranularity(DateGranularity dateGranularity)
 {
     throw new global::System.NotImplementedException("GroupingInfo.SetDateGranularity");
 }
Beispiel #8
0
        /// <summary>
        /// Set the date the photo was posted (uploaded) and the date the photo was taken.
        /// Changing the date posted will affect the order in which photos are seen in your photostream.
        /// </summary>
        /// <remarks>
        /// All dates are assumed to be GMT. It is the developers responsibility to change dates to the local users 
        /// timezone.
        /// </remarks>
        /// <param name="photoId">The id of the photo to set the dates.</param>
        /// <param name="datePosted">The new date to set the date posted too.</param>
        /// <param name="dateTaken">The new date to set the date taken too.</param>
        /// <param name="granularity">The granularity of the date taken.</param>
        /// <returns>True if the dates where updated successfully.</returns>
        public bool PhotosSetDates(string photoId, DateTime datePosted, DateTime dateTaken, DateGranularity granularity)
        {
            Hashtable parameters = new Hashtable();
            parameters.Add("method", "flickr.photos.setDates");
            parameters.Add("photo_id", photoId);
            if( datePosted != DateTime.MinValue ) parameters.Add("date_posted", Utils.DateToUnixTimestamp(datePosted).ToString());
            if( dateTaken != DateTime.MinValue )
            {
                parameters.Add("date_taken", dateTaken.ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo));
                parameters.Add("date_taken_granularity", granularity.ToString("d"));
            }

            FlickrNet.Response response = GetResponseNoCache(parameters);

            if( response.Status == ResponseStatus.OK )
            {
                return true;
            }
            else
            {
                throw new FlickrException(response.Error);
            }
        }
Beispiel #9
0
 /// <summary>
 /// Set the date taken for a photo.
 /// </summary>
 /// <remarks>
 /// All dates are assumed to be GMT. It is the developers responsibility to change dates to the local users 
 /// timezone.
 /// </remarks>
 /// <param name="photoId">The id of the photo to set the date taken for.</param>
 /// <param name="dateTaken">The date taken.</param>
 /// <param name="granularity">The granularity of the date taken.</param>
 /// <returns>True if the date was updated successfully.</returns>
 public bool PhotosSetDates(string photoId, DateTime dateTaken, DateGranularity granularity)
 {
     return PhotosSetDates(photoId, DateTime.MinValue, dateTaken, granularity);
 }
 public void PhotosSetDates(string photoId, DateTime datePosted, DateTime dateTaken, DateGranularity granularity);
 public void PhotosSetDates(string photoId, DateTime? datePosted, DateTime? dateTaken, DateGranularity granularity)
 {
     var dictionary = new Dictionary<string, string>();
     dictionary.Add("method", "flickr.photos.setDates");
     dictionary.Add("photo_id", photoId);
     if (datePosted != null) dictionary.Add("date_posted", datePosted.Value.ToUnixTimestamp());
     if (dateTaken != null) dictionary.Add("date_taken", dateTaken.Value.ToUnixTimestamp());
     if (granularity != DateGranularity.FullDate) dictionary.Add("granularity", granularity.ToString().ToLower());
     GetResponse<NoResponse>(dictionary);
 }
 /// <summary>
 /// Set the date taken for a photo.
 /// </summary>
 /// <remarks>
 /// All dates are assumed to be GMT. It is the developers responsibility to change dates to the local users 
 /// timezone.
 /// </remarks>
 /// <param name="photoId">The id of the photo to set the date taken for.</param>
 /// <param name="dateTaken">The date taken.</param>
 /// <param name="granularity">The granularity of the date taken.</param>
 /// <returns>True if the date was updated successfully.</returns>
 public void PhotosSetDates(string photoId, DateTime dateTaken, DateGranularity granularity)
 {
     PhotosSetDates(photoId, DateTime.MinValue, dateTaken, granularity);
 }
Beispiel #13
0
 public DateDimension(string name, DateGranularity granularity) : base(name, new List <StarColumn>(), null)
 {
     Granularity = granularity;
 }
Beispiel #14
0
 /// <summary>
 /// Set the date taken for a photo.
 /// </summary>
 /// <remarks>
 /// All dates are assumed to be GMT. It is the developers responsibility to change dates to the local users 
 /// timezone.
 /// </remarks>
 /// <param name="photoId">The id of the photo to set the date taken for.</param>
 /// <param name="dateTaken">The date taken.</param>
 /// <param name="granularity">The granularity of the date taken.</param>
 /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
 public async Task<FlickrResult<NoResponse>> PhotosSetDatesAsync(string photoId, DateTime dateTaken, DateGranularity granularity)
 {
     return await PhotosSetDatesAsync(photoId, DateTime.MinValue, dateTaken, granularity);
 }
 /// <summary>
 /// Set the date taken for a photo.
 /// </summary>
 /// <remarks>
 /// All dates are assumed to be GMT. It is the developers responsibility to change dates to the local users 
 /// timezone.
 /// </remarks>
 /// <param name="photoId">The id of the photo to set the date taken for.</param>
 /// <param name="dateTaken">The date taken.</param>
 /// <param name="granularity">The granularity of the date taken.</param>
 /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
 public void PhotosSetDatesAsync(string photoId, DateTime dateTaken, DateGranularity granularity, Action<FlickrResult<NoResponse>> callback)
 {
     PhotosSetDatesAsync(photoId, DateTime.MinValue, dateTaken, granularity, callback);
 }
        /// <summary>
        /// Set the date the photo was posted (uploaded) and the date the photo was taken.
        /// Changing the date posted will affect the order in which photos are seen in your photostream.
        /// </summary>
        /// <remarks>
        /// All dates are assumed to be GMT. It is the developers responsibility to change dates to the local users 
        /// timezone.
        /// </remarks>
        /// <param name="photoId">The id of the photo to set the dates.</param>
        /// <param name="datePosted">The new date to set the date posted too.</param>
        /// <param name="dateTaken">The new date to set the date taken too.</param>
        /// <param name="granularity">The granularity of the date taken.</param>
        /// <param name="callback">Callback method to call upon return of the response from Flickr.</param>
        public void PhotosSetDatesAsync(string photoId, DateTime datePosted, DateTime dateTaken, DateGranularity granularity, Action<FlickrResult<NoResponse>> callback)
        {
            Dictionary<string, string> parameters = new Dictionary<string, string>();
            parameters.Add("method", "flickr.photos.setDates");
            parameters.Add("photo_id", photoId);
            if (datePosted != DateTime.MinValue) parameters.Add("date_posted", UtilityMethods.DateToUnixTimestamp(datePosted).ToString());
            if (dateTaken != DateTime.MinValue)
            {
                parameters.Add("date_taken", dateTaken.ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.DateTimeFormatInfo.InvariantInfo));
                parameters.Add("date_taken_granularity", granularity.ToString("d"));
            }

            GetResponseAsync<NoResponse>(parameters, callback);
        }
 public void PhotosSetDates(string photoId, DateTime? dateTaken, DateGranularity granularity)
 {
     PhotosSetDates(photoId, null, dateTaken, granularity);
 }