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

Seagate Date Code Calculator

By , 6 Aug 2007
 

Screenshot - SeagateDateCode.jpg

Introduction

The code described in this article helps users convert Seagate's (the hard drive manufacture) date code to a DateTime value.

This article is based on this documentation.

Background

I had to check some hard drives for warranty, and found myself checking very old hard drives.

The code

Here is the actual code invloved:

Class variables

private DateTime datecalc;
private string _datecode;

Class properties

public string DateCode
{
    get { return _datecode; }
    set 
    {
        int _CodeYear = 0;
        byte _CodeWeek = 0;
        byte _CodeDayOfWeek = 0;
        _datecode = value;
        if (_datecode.Length == 5)
        {
            //Get the number of weeks to add
            _CodeWeek = Convert.ToByte(_datecode.Substring(2, 2));
            //Get the day of the week in the final week
            _CodeDayOfWeek = Convert.ToByte(_datecode.Substring(4));
        }
        else if (_datecode.Length == 4)
        {
            //Get the number of weeks to add
            _CodeWeek = Convert.ToByte(_datecode.Substring(2, 1));
            //Get the day of the week in the final week
            _CodeDayOfWeek = Convert.ToByte(_datecode.Substring(3));
        }
        if (_datecode.Length == 4 || _datecode.Length == 5)
        {
            _CodeWeek--;
            _CodeDayOfWeek--;
            _CodeYear = (2000 + Convert.ToInt32(_datecode.Substring(0, 2)) - 1);
            datecalc = new DateTime(_CodeYear, 7, 1);
            datecalc.AddDays(-1);
            do { datecalc = datecalc.AddDays(1); } 
            while (datecalc.DayOfWeek != DayOfWeek.Saturday);
            datecalc = datecalc.AddDays((_CodeWeek * 7) + _CodeDayOfWeek);
        }
    }
}

public DateTime CalculatedDate
{
    get { return datecalc; }
}

Class constructors

public SeagateDateCodeCalc()
{

}
public SeagateDateCodeCalc(string dateCode)
{
    this.DateCode = dateCode;
}

History

This is my first submission here, so let me know if I am missing anything.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Paw Jershauge
Software Developer
Denmark Denmark
Member

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
GeneralRunning the progmembergimmegimme8 Oct '08 - 11:00 
Interesting how the coders never seem to care about people who might want to code or experiment, but don't know how. Perhaps it is not to late to explain to a nOob how to run the prog?
GeneralRe: Running the prog PinmemberPaw Jershauge9 Oct '08 - 2:42 
What do you mean??
Do you have Visual Studio installed on your computer ???
 
What is it that you would like to know ???
 
With great code, comes great complexity, so keep it simple stupid...Shucks | :-> Shucks | :->

GeneralRe: Running the prog Pinmembericefloe018 Jan '09 - 4:37 
I believe their point is this; If someone happens upon this from a search engine, creates a login to get the file, and extracts it (like me), it is not immediately obvious that you have to drill down through several folders to find the executeable. Does the executeable have to be all the down in the bin folder to work or can it be moved to the top folder? It would be much easier for the inexperienced (that includes me) to be able to use this calculator if the executeable was in the first folder that's opened. I'm glad you made it though as saves me a bunch of headscratching to create an Excel script to do it. So I give the project an excellent rating as far as it's usefulness to me, but a 2 for useability. When I first extracted it, I looked in the first folder, did not see an exe, looked in the second folder, did not see an exe and almost gave up. I was about to ask online if anyone had a compiler to make an exe out of it, and then decided to keep digging through the folders. Now I'm glad I did.
GeneralRe: Running the prog PinmemberPaw Jershauge8 Jan '09 - 10:14 
I'm sorry you feel this way, but im glad you like the program.
But first of all, this is a website for and by developers.
 
This site is not an software distribution site like download.com thats why you had to drill down into folders.
 
Most users here dont even post the executable files whitin the zip file.
 
For what its worth, im glad you can use the software. Wink | ;)
 
Best regards...
 
With great code, comes great complexity, so keep it simple stupid...Shucks | :-> Shucks | :->

GeneralRe: Running the prog Pinmembericefloe018 Jan '09 - 11:40 
Please don't get the wrong impression, I wasn't trying to bash you. I spent a LOT of time trying to organize my thoughts so that I would not come across that way. I was just trying express why I thought they said what they said. I had also spent quite some time (30-45 min) trying to find a simple solution to decoding the Seagate date code when Google popped up your project. I had some ideas in mind for an Excel spreadsheet to do it and was about to pursue that when codeproject popped up. I actually had Visual Studio Express installed (hadn't gotten around to learning it yet) when I had XP Pro installed. I haven't downloaded the latest version since upgrading to Vista Ultimate 64, but I do want to get into programming sometime this year as it will help out quite a bit at work too. Once again, I apologize if I came across as harsh, that was not my intent. Smile | :)
GeneralRe: Running the prog PinmemberKnight of Cydonia11 Jan '09 - 12:37 
I've been looking to write a VBA for Excel to do this but I thought this program would save me a bit of time. I've tried the running the .exe's but nothing seems to be happening. Is there anything I have to do in addition. I'm just following the folder structure and double clicking the .exe. Your help would be appriciated as I would regularly be using this for my line of work.
GeneralRe: Running the prog PinmemberPaw Jershauge11 Jan '09 - 23:47 
The Application should start if you double click on the exe file... if not, then there should come an Error message or something.
 
With great code, comes great complexity, so keep it simple stupid...Shucks | :-> Shucks | :->

GeneralRe: Running the prog PinmemberKnight of Cydonia12 Jan '09 - 8:29 
Thanks for replying. I had tried to run it on XP64 without success. Didn't run and there were no error messages. I have since tried it on XP32 and it runs fine. Great little prog. It will save us some time, won't need calendars anymore.

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

Permalink | Advertise | Privacy | Mobile
Web01 | 2.6.130523.1 | Last Updated 6 Aug 2007
Article Copyright 2007 by Paw Jershauge
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid