DriveHQ Start Menu
Cloud Drive Mapping
Folder Sync
Cloud Backup
True Drop Box
FTP/SFTP Hosting
Group Account
DriveHQ Start Menu
Online File Server
My Storage
|
Manage Shares
|
Publishes
|
Drop Boxes
|
Group Account
WebDAV Drive Mapping
Cloud Drive Home
|
WebDAV Guide
|
Drive Mapping Tool
|
Drive Mapping URL
Complete Data Backup
Backup Guide
|
Online Backup Tool
|
Cloud-to-Cloud Backup
FTP, Email & Web Service
FTP Home
|
FTP Hosting FAQ
|
Email Hosting
|
EmailManager
|
Web Hosting
Help & Resources
About
|
Enterprise Service
|
Partnership
|
Comparisons
|
Support
Quick Links
Security and Privacy
Download Software
Service Manual
Use Cases
Group Account
Online Help
Blog
Contact
Cloud Surveillance
Sign Up
Login
Features
Business Features
Online File Server
FTP Hosting
Cloud Drive Mapping
Cloud File Backup
Email Backup & Hosting
Cloud File Sharing
Folder Synchronization
Group Management
True Drop Box
Full-text Search
AD Integration/SSO
Mobile Access
IP Camera & DVR Solution
More...
Personal Features
Personal Cloud Drive
Backup All Devices
Mobile APPs
Personal Web Hosting
Sub-Account (for Kids)
Home/PC/Kids Monitoring
More...
Software
DriveHQ Drive Mapping Tool
DriveHQ FileManager
DriveHQ Online Backup
DriveHQ Mobile Apps
Pricing
Business Plans & Pricing
Personal Plans & Pricing
Price Comparison with Others
Feature Comparison with Others
Install Mobile App
Sign up
Creating account...
Invalid character in username! Only 0-9, a-z, A-Z, _, -, . allowed.
Username is required!
Invalid email address!
E-mail is required!
Password is required!
Password is invalid!
Password and confirmation do not match.
Confirm password is required!
I accept
Membership Agreement
Please read the Membership Agreement and check "I accept"!
Free Quick Sign-up
Sign-up Page
Log in
Signing in...
Username or e-mail address is required!
Password is required!
Keep me logged in
Quick Login
Forgot Password
Up
Upload
Download
Share
Publish
New Folder
New File
Copy
Cut
Delete
Paste
Rate
Upgrade
Rotate
Effect
Edit
Slide
History
#ifndef DATE_DURATION_TYPES_HPP___ #define DATE_DURATION_TYPES_HPP___ /* Copyright (c) 2004 CrystalClear Software, Inc. * Subject to the Boost Software License, Version 1.0. * (See accompanying file LICENSE_1_0.txt or * http://www.boost.org/LICENSE_1_0.txt) * Author: Jeff Garland, Bart Garst * $Date: 2008-02-27 15:00:24 -0500 (Wed, 27 Feb 2008) $ */ #include
#include
#include
namespace boost { namespace date_time { //! Additional duration type that represents a number of n*7 days template
class weeks_duration : public date_duration
{ public: weeks_duration(typename duration_config::impl_type w) : date_duration
(w * 7) {} weeks_duration(special_values sv) : date_duration
(sv) {} }; // predeclare template
class years_duration; //! additional duration type that represents a logical month /*! A logical month enables things like: "date(2002,Mar,2) + months(2) -> * 2002-May2". If the date is a last day-of-the-month, the result will * also be a last-day-of-the-month. */ template
class months_duration { private: typedef typename base_config::int_rep int_rep; typedef typename int_rep::int_type int_type; typedef typename base_config::date_type date_type; typedef typename date_type::duration_type duration_type; typedef typename base_config::month_adjustor_type month_adjustor_type; typedef months_duration
months_type; typedef years_duration
years_type; public: months_duration(int_rep num) : _m(num) {} months_duration(special_values sv) : _m(sv) { _m = int_rep::from_special(sv); } int_rep number_of_months() const { return _m; } //! returns a negative duration duration_type get_neg_offset(const date_type& d) const { month_adjustor_type m_adj(_m.as_number()); return duration_type(m_adj.get_neg_offset(d)); } duration_type get_offset(const date_type& d) const { month_adjustor_type m_adj(_m.as_number()); return duration_type(m_adj.get_offset(d)); } bool operator==(const months_type& rhs) const { return(_m == rhs._m); } bool operator!=(const months_type& rhs) const { return(_m != rhs._m); } months_type operator+(const months_type& rhs)const { return months_type(_m + rhs._m); } months_type& operator+=(const months_type& rhs) { _m = _m + rhs._m; return *this; } months_type operator-(const months_type& rhs)const { return months_type(_m - rhs._m); } months_type& operator-=(const months_type& rhs) { _m = _m - rhs._m; return *this; } months_type operator*(const int_type rhs)const { return months_type(_m * rhs); } months_type& operator*=(const int_type rhs) { _m = _m * rhs; return *this; } months_type operator/(const int_type rhs)const { return months_type(_m / rhs); } months_type& operator/=(const int_type rhs) { _m = _m / rhs; return *this; } months_type operator+(const years_type& y)const { return months_type(y.number_of_years() * 12 + _m); } months_type& operator+=(const years_type& y) { _m = y.number_of_years() * 12 + _m; return *this; } months_type operator-(const years_type& y) const { return months_type(_m - y.number_of_years() * 12); } months_type& operator-=(const years_type& y) { _m = _m - y.number_of_years() * 12; return *this; } // friend date_type operator+(const date_type& d, const months_type& m) { return d + m.get_offset(d); } friend date_type operator+=(date_type& d, const months_type& m) { return d += m.get_offset(d); } friend date_type operator-(const date_type& d, const months_type& m) { // get_neg_offset returns a negative duration, so we add return d + m.get_neg_offset(d); } friend date_type operator-=(date_type& d, const months_type& m) { // get_neg_offset returns a negative duration, so we add return d += m.get_neg_offset(d); } private: int_rep _m; }; //! additional duration type that represents a logical year /*! A logical year enables things like: "date(2002,Mar,2) + years(2) -> * 2004-Mar-2". If the date is a last day-of-the-month, the result will * also be a last-day-of-the-month (ie date(2001-Feb-28) + years(3) -> * 2004-Feb-29). */ template
class years_duration { private: typedef typename base_config::int_rep int_rep; typedef typename int_rep::int_type int_type; typedef typename base_config::date_type date_type; typedef typename date_type::duration_type duration_type; typedef typename base_config::month_adjustor_type month_adjustor_type; typedef years_duration
years_type; typedef months_duration
months_type; public: years_duration(int_rep num) : _y(num) {} years_duration(special_values sv) : _y(sv) { _y = int_rep::from_special(sv); } int_rep number_of_years() const { return _y; } //! returns a negative duration duration_type get_neg_offset(const date_type& d) const { month_adjustor_type m_adj(_y.as_number() * 12); return duration_type(m_adj.get_neg_offset(d)); } duration_type get_offset(const date_type& d) const { month_adjustor_type m_adj(_y.as_number() * 12); return duration_type(m_adj.get_offset(d)); } bool operator==(const years_type& rhs) const { return(_y == rhs._y); } bool operator!=(const years_type& rhs) const { return(_y != rhs._y); } years_type operator+(const years_type& rhs)const { return years_type(_y + rhs._y); } years_type& operator+=(const years_type& rhs) { _y = _y + rhs._y; return *this; } years_type operator-(const years_type& rhs)const { return years_type(_y - rhs._y); } years_type& operator-=(const years_type& rhs) { _y = _y - rhs._y; return *this; } years_type operator*(const int_type rhs)const { return years_type(_y * rhs); } years_type& operator*=(const int_type rhs) { _y = _y * rhs; return *this; } years_type operator/(const int_type rhs)const { return years_type(_y / rhs); } years_type& operator/=(const int_type rhs) { _y = _y / rhs; return *this; } months_type operator+(const months_type& m) const { return(months_type(_y * 12 + m.number_of_months())); } months_type operator-(const months_type& m) const { return(months_type(_y * 12 - m.number_of_months())); } // friend date_type operator+(const date_type& d, const years_type& y) { return d + y.get_offset(d); } friend date_type operator+=(date_type& d, const years_type& y) { return d += y.get_offset(d); } friend date_type operator-(const date_type& d, const years_type& y) { // get_neg_offset returns a negative duration, so we add return d + y.get_neg_offset(d); } friend date_type operator-=(date_type& d, const years_type& y) { // get_neg_offset returns a negative duration, so we add return d += y.get_neg_offset(d); } private: int_rep _y; }; }} // namespace boost::date_time #endif // DATE_DURATION_TYPES_HPP___
date_duration_types.hpp
Page URL
File URL
Prev
10/60
Next
Download
( 8 KB )
Note: The DriveHQ service banners will NOT be displayed if the file owner is a paid member.
Comments
Total ratings:
0
Average rating:
Not Rated
Would you like to comment?
Join DriveHQ
for a free account, or
Logon
if you are already a member.