Click here to Skip to main content
Licence CPOL
First Posted 6 Aug 2007
Views 45,381
Downloads 182
Bookmarked 15 times

Seagate Date Code Calculator

By | 6 Aug 2007 | Article
How to get the date 20 November 2005 from the number 06212.

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

blog: C# And I
About.me Paw Jershauge
ListView Group Sorter
An Code Generator, for making SQL table into .Net Classses (2nd place in the Code Generation 2008 Competition)
A Class for getting the Rss feed list of a website
Seagate Date Code Calculator
DNSBL lookup Class
Base N converter (N = 10-62)
Lightweight Directory Access Protocol Uniform resource identifier (LDAPUri)
LoginHours from DirectoryEntry into boolean array

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. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
GeneralRunning the prog Pinmembergimmegimme11:00 8 Oct '08  
GeneralRe: Running the prog PinmemberPaw Jershauge2:42 9 Oct '08  
GeneralRe: Running the prog Pinmembericefloe014:37 8 Jan '09  
GeneralRe: Running the prog PinmemberPaw Jershauge10:14 8 Jan '09  
GeneralRe: Running the prog Pinmembericefloe0111:40 8 Jan '09  
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 Cydonia12:37 11 Jan '09  
GeneralRe: Running the prog PinmemberPaw Jershauge23:47 11 Jan '09  
GeneralRe: Running the prog PinmemberKnight of Cydonia8:29 12 Jan '09  

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.

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