Click here to Skip to main content
11,437,713 members (34,791 online)
Click here to Skip to main content

Seagate Date Code Calculator

, 6 Aug 2007 CPOL
Rate this:
Please Sign up or sign in to vote.
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)

Share

About the Author


Comments and Discussions

 
QuestionThank You! Pin
Jason Bradley Smith13-Nov-14 15:24
memberJason Bradley Smith13-Nov-14 15:24 
AnswerRe: Thank You! Pin
Paw Jershauge19-Nov-14 6:08
professionalPaw Jershauge19-Nov-14 6:08 
GeneralRunning the prog Pin
gimmegimme8-Oct-08 12:00
membergimmegimme8-Oct-08 12:00 
GeneralRe: Running the prog Pin
Paw Jershauge9-Oct-08 3:42
memberPaw Jershauge9-Oct-08 3:42 
GeneralRe: Running the prog Pin
icefloe018-Jan-09 5:37
membericefloe018-Jan-09 5:37 
GeneralRe: Running the prog Pin
Paw Jershauge8-Jan-09 11:14
memberPaw Jershauge8-Jan-09 11:14 
GeneralRe: Running the prog Pin
icefloe018-Jan-09 12:40
membericefloe018-Jan-09 12:40 
GeneralRe: Running the prog Pin
Knight of Cydonia11-Jan-09 13:37
memberKnight of Cydonia11-Jan-09 13:37 
GeneralRe: Running the prog Pin
Paw Jershauge12-Jan-09 0:47
memberPaw Jershauge12-Jan-09 0:47 
GeneralRe: Running the prog Pin
Knight of Cydonia12-Jan-09 9:29
memberKnight of Cydonia12-Jan-09 9:29 

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 | Terms of Use | Mobile
Web03 | 2.8.150506.1 | Last Updated 6 Aug 2007
Article Copyright 2007 by Paw Jershauge
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid