Click here to Skip to main content
Click here to Skip to main content

Non-MFC Date Routines in ATL

, 8 Sep 2000
Rate this:
Please Sign up or sign in to vote.
Non-MFC Date Routines in an ATL Component.
  • Download demo project - 5 Kb
  • Download source files - 5 Kb
  • When writing ATL components, one of the hardest things to overcome for Windows programmers, in my opinion, is the dependency on the MFC library. For dates and strings, MFC simplifies the programmer's job by handling memory allocations and type conversions within its class encapsulation. However, with that simplification comes the price of having to distribute the MFC DLL's with your component.

    This article focuses on the issues surrounding the use of dates within an ATL component. I developed the DateLib component as part of a project for my company and, as such, the methods of this component are specific to my company's requirements (I do not have an intellectual property agreement with this company). However, the DateLib component does illustrate how to build an ATL component that has no MFC dependencies, is thread-safe, and will compile as either ANSI or UNICODE.

    The methods within the DateLib component are as follows:

    Date Formatting Routines:

    • Now - Returns the current system date in a DATE variable.
    • OLE2Oracle - For a given DATE, returns a formatted string using the DD-Mon-YYYY representation.
    • Int2Oracle - For a given month, day, and year, returns a formatted string using the DD-Mon-YYYY representation.
    • Int2OLE - For a given month, day, and year, returns the date in a DATE variable.
    • OLE2String - For a given DATE, returns a formatted string using the MM/DD/YYYY representation.


    Date Parsing Routines:

    • ParseOracle2OLE - For a given date given in a M/D/YY format, returns the date in a DATE variable.
    • ParseOracle2String - For a given date given in a M/D/YY format, returns a formatted string using the MM/DD/YYYY representation.
    • ParseOracle2Oracle - For a given date given in a M/D/YY format, returns a formatted string using the DD-Mon-YYYY representation.


    Date Math Routines:

    • GetFirstDay - For a given DATE, returns the first day of the month in a DATE variable.
    • GetLastDay - For a given DATE, returns the last day of the month in a DATE variable.
    • GetNextDay - For a given DATE, returns the next day's date in a DATE variable.
    • GetNextWeek - For a given DATE, returns the next week's date in a DATE variable.
    • GetNextMonth - For a given DATE, returns the next month's date in a DATE variable.
    • GetNextYear - For a given DATE, returns the next year's date in a DATE variable.
    • GetPreviousDay - For a given DATE, returns the previous day's date in a DATE variable.
    • GetPreviousWeek - For a given DATE, returns the previous week's date in a DATE variable.
    • GetPreviousMonth - For a given DATE, returns the previous month's date in a DATE variable.
    • GetPreviousYear - For a given DATE, returns the previous year's date in a DATE variable.


    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here

    About the Author

    Paul E. Bible
    Software Developer (Senior)
    United States United States
    Eat, Sleep, Code, Bike. That about sums it up!!

    Comments and Discussions

     
    GeneralBug in OLE2Oracle PinsussRainer Schuetz31-Aug-00 2:19 
    GeneralRe: Bug in OLE2Oracle PinsussPaul E. Bible2-Sep-00 17:01 
    General[Message Removed] Pinmemberstonber1-Oct-08 7:46 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    | Advertise | Privacy | Mobile
    Web01 | 2.8.140721.1 | Last Updated 9 Sep 2000
    Article Copyright 2000 by Paul E. Bible
    Everything else Copyright © CodeProject, 1999-2014
    Terms of Service
    Layout: fixed | fluid